This script uses a simluated dataset (data_simulated.csv) to demo the code used in the manuscript Querdasi, Uy et al. “Childhood gut microbiome is linked to mental health at school age via the functional connectome”. Because the simulated data are not real, results are not expected to be equivalent to those reported in the paper.

Setup

Set seed

main.seed = 6024

Load libraries

suppressPackageStartupMessages({
  library(tidyverse)
  library(mixOmics)
  library(readxl)
  library(vegan)
  library(compositions)
  library(mosaic)
  library(Hmisc)
  library(rstatix)
  library(sjPlot)
  library(patchwork)
  library(corrplot)
  library(MASS) # for box-cox transformation
})

# change this path below to be the location of the process macro script in your path
source("../collab_jess_fran/PROCESS v4.3 for R/process.R")
## 
## ********************* PROCESS for R Version 4.3.1 ********************* 
##  
##            Written by Andrew F. Hayes, Ph.D.  www.afhayes.com              
##    Documentation available in Hayes (2022). www.guilford.com/p/hayes3   
##  
## *********************************************************************** 
##  
## PROCESS is now ready for use.
## Copyright 2020-2023 by Andrew F. Hayes ALL RIGHTS RESERVED
## Workshop schedule at http://haskayne.ucalgary.ca/CCRAM
## 

Load demo dataset

sim_data <- read_csv("data_simulated.csv")
## Rows: 66 Columns: 210
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (36): subID, only_bf_months, any_bf_months, ethnicity, cbclq5_y7, cbclq...
## dbl (174): meanFD_centered, sex_centered, GA_centered, BW_centered, deliv_mo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Analyses

Identification of Brain Signatures

Brain –> Internalizing Symptoms sPLS1 models (X is matrix, Y is univariate) Vignette for sPLS1 regression models: https://mixomicsteam.github.io/mixOmics-Vignette/id_04.html#id_04:spls1

Note: data in spls are scaled by default

# select brain data for participants who have cbcl data (N=55)
brain_vars <- sim_data %>% 
  dplyr::filter(!is.na(cbclintprobtot_y7)) %>% 
  dplyr::select(DMN:MTL_PMN) 

cbcl_comp_dataset <- sim_data %>% 
  dplyr::filter(!is.na(cbclintprobtot_y7))

# initial sPLS model (should specify a large number of components first)
tune.spls1.int.brain <- pls(X=brain_vars, Y=cbcl_comp_dataset$cbclintprobtot_y7, ncomp=4, mode='regression')

# use R^2 criterion to define the ideal number of dimensions/components (using repeated 10-fold cross validation)
set.seed(main.seed)
R2.spls1.int.brain <- perf(tune.spls1.int.brain, validation='Mfold',
                           folds=10, nrepeat=50)

plot(R2.spls1.int.brain, criterion = 'R2') # best for this demo dataset is 1 component

# for the sake of consistency in number of models run with real dataset, we will set the number of components to 2

# add a constant to all cbcl scores to avoid the error for tune.spls
rownames(brain_vars) <- cbcl_comp_dataset$subID
## Warning: Setting row names on a tibble is deprecated.
rownames(cbcl_comp_dataset) <- cbcl_comp_dataset$subID
## Warning: Setting row names on a tibble is deprecated.
cbclintprobtot_y7 <- cbcl_comp_dataset$cbclintprobtot_y7
cbclintprobtot_y7$cbclintprobtot_y7 <- cbcl_comp_dataset$cbclintprobtot_y7 + 1
## Warning in cbclintprobtot_y7$cbclintprobtot_y7 <-
## cbcl_comp_dataset$cbclintprobtot_y7 + : Coercing LHS to a list
# evaluate number of variables to select from X matrix (using number of components selected above)
# set up list of values
list.keepX <- c(5:10, seq(15, 50, 5)) # this should be thin at the start, and restricted to a small number of networks for a parsimonious model

# use R^2 criterion to define the ideal number of dimensions/components (using repeated 10-fold cross validation)
set.seed(main.seed)
tune.spls1.brain.win.r2 <- mixOmics::tune.spls(brain_vars, cbclintprobtot_y7$cbclintprobtot_y7, ncomp= 2, 
                            test.keepX = list.keepX, 
                            validation = 'Mfold', 
                            folds = 10,
                            nrepeat = 100, 
                            progressBar = TRUE,
                            measure = 'R2') 
## 
## comp 1 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
## comp 2 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
plot(tune.spls1.brain.win.r2) # best is 5 features for 2nd component and 5 features for 1st

#how many components to keep w this?
choice.ncomp <- 2 #2 components, set from above
# how many x variables with 1 component? 5
choice.keepX <- tune.spls1.brain.win.r2$choice.keepX[1:choice.ncomp] #5 features on component 1, 5 features on component 2

# specify final model with 2 component and 5, 5 brain features
spls1.int.brain <- spls(X=brain_vars, Y=cbclintprobtot_y7$cbclintprobtot_y7, ncomp = choice.ncomp, keepX = choice.keepX, mode = "regression")

# extract list of features that were selected (each component is orthogonal)
selectVar(spls1.int.brain, comp = 1)$X$name # "SML"     "VIS_MTL" "FPN_SML" "AUD"     "SAL"    
## [1] "SML"     "VIS_MTL" "FPN_SML" "AUD"     "SAL"
selectVar(spls1.int.brain, comp = 2)$X$name # "DMN_VIS" "FPN_REW" "DMN_MTL" "DMN_SML" "DAN_PMN"
## [1] "DMN_VIS" "FPN_REW" "DMN_MTL" "DMN_SML" "DAN_PMN"
# what proportion of variance in internalizing is explained by the brain component?
spls1.int.brain$prop_expl_var$X #2, 3% of the variance
##      comp1      comp2 
## 0.02948382 0.03070736
tune.spls1.int.brain$prop_expl_var$X #39% of variance explained by component 1 (more than pre-tuning)
##      comp1      comp2      comp3      comp4 
## 0.03430027 0.02477744 0.02836561 0.02920695
# plots of the results
#plot the component associated to the  X data set (here corresponding to a linear combination of the selected genes) vs. the component associated to the y variable (corresponding to the scaled y variable in PLS1 with one dimension)

plot(spls1.int.brain$variates$X, spls1.int.brain$variates$Y,
     xlab = 'X component', ylab = 'y component / scaled y') #no outliers 

cor(spls1.int.brain$variates$X, spls1.int.brain$variates$Y) #0.53
##           comp1        comp2
## comp1 0.5339478 1.829537e-16
## comp2 0.4165317 4.926352e-01

Investigate and deal with brain outliers

In the actual results, 2 brain outliers showed up in the scatterplot with the components for internalizing Though no outliers were present in the simulated data, we will pick the participants with the two highest component 2 scores to winsorize in order to demo the code used to winsorize the outliers in the main script/with the real dataset.

# extract component scores to identify outlier IDs
brain_cbcl <- as.data.frame(spls1.int.brain$variates$X) # G43 and G18 have highest comoponent 2 scores

# based on the component scores from the brain-internalizing spls regression, we will designate G18 and G43 as high multivariate outliers

brain_outliers <- cbcl_comp_dataset %>% 
  dplyr::select(subID, DMN:MTL_PMN) %>% 
  dplyr::filter(
    subID == "G18" | subID == "G43"
  )

# get the ranges for all networks in the matrix
brain_means <- as.data.frame(colMeans(brain_vars[2:91]))

# check distribution of each brain network -- on the whole, look relatively normal (some are slightly skewed)
hist.data.frame(brain_vars)

# Calculate the variance of each variable
variances <- sapply(brain_vars, var)

# Sort the variances from highest to lowest
sorted_variances <- as.data.frame(sort(variances, decreasing = TRUE))
colnames(sorted_variances) <- c("variance")
sorted_variances <- sorted_variances %>% rownames_to_column(var = "variable")

# Get the variable names corresponding to the sorted variances
sorted_variable_names <- names(sorted_variances)

# identify if the two multivariate outliers (G14 and G18) are univariate outliers on any networks
cbcl_comp_dataset %>% 
  dplyr::select(subID, DMN:MTL_PMN) %>%
  pivot_longer(-subID) %>% #To make the data in long form required for `tidyverse`
  group_by(name) %>% #Based on which column you want to aggregate 
  identify_outliers(value) %>% 
  select(name, subID, value, is.outlier, is.extreme) %>% # extreme = Q3 + 3*IQR, outlier = Q3 + 1.5*IQR
  dplyr::filter(subID=="G18" | subID=="G43") 
## # A tibble: 1 × 5
##   name    subID   value is.outlier is.extreme
##   <chr>   <chr>   <dbl> <lgl>      <lgl>     
## 1 DAN_REW G43   -0.0922 TRUE       FALSE
# G43 is outlier on DAN_REW

Create brain dataset with brain outliers winsorized to next highest values

For the sake of illustration in the demo code, we will winsorize G43 on DAN_REW

# initialize a new dataset
brain_cbcl_win <- cbcl_comp_dataset %>% 
  dplyr::select(subID, DMN:MTL_PMN)

# get the second highest FPN_VIS value to replace the outlier with
top_2_DAN_REW_values <- brain_cbcl_win %>% 
  arrange(desc(DAN_REW)) %>% 
  slice_head(n=5) %>% 
  dplyr::select(DAN_REW)

#top_2_FPN_VIS_values$FPN_VIS[2]

# replace both outlier sub's values with the next highest
brain_cbcl_win$DAN_REW[brain_cbcl_win$subID=="G43"] <- top_2_DAN_REW_values$DAN_REW[2]

Tune the Brain –> Internalizing Symptoms sPLS models with the winsorized dataset

brain_cbcl_win_noids <- brain_cbcl_win %>% dplyr::select(-subID)
rownames(brain_cbcl_win_noids) <- brain_cbcl_win$subID
## Warning: Setting row names on a tibble is deprecated.
# initial sPLS model (should specify a large number of components first)
tune.spls1.int.brain.win <- pls(X=brain_cbcl_win_noids, Y=cbclintprobtot_y7$cbclintprobtot_y7, ncomp=4, mode='regression')

# use R^2 criterion to define the ideal number of dimensions/components (using repeated 10-fold cross validation)
set.seed(main.seed)
R2.spls1.int.brain.win <- perf(tune.spls1.int.brain.win, validation='Mfold',
                           folds=10, nrepeat=50)

plot(R2.spls1.int.brain.win, criterion = 'R2') # same as before, best for this demo dataset is 1 components, but we will select 2 for the sake of demonstrating a process identical to the script with the real dataset

# use R^2 criterion to define the ideal number of dimensions/components (using repeated 10-fold cross validation)
set.seed(main.seed)
tune.spls1.brain.win.r2 <- mixOmics::tune.spls(brain_cbcl_win_noids, cbclintprobtot_y7$cbclintprobtot_y7, ncomp= 2, 
                            test.keepX = list.keepX, 
                            validation = 'Mfold', 
                            folds = 10,
                            nrepeat = 100, 
                            progressBar = TRUE,
                            measure = 'R2') 
## 
## comp 1 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
## comp 2 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
plot(tune.spls1.brain.win.r2) # same as before for number of features per component

#how many components to keep w this?
choice.ncomp.r2 <- 2 # set from before
choice.keepX_2.r2 <- tune.spls1.brain.win.r2$choice.keepX[1:2] #5 features comp1, 5 comp2 

# specify final model with same number of features as before 
spls1.int.brain.win <- spls(X=brain_cbcl_win_noids, Y=cbcl_comp_dataset$cbclintprobtot_y7, ncomp = 2, keepX = choice.keepX_2.r2, mode = "regression")

# extract list of features that were selected (each component is orthogonal)
selectVar(spls1.int.brain.win, comp = 1)$X$name # "VAN_SMD" "REW_MTL" "VAN_VIS" "DMN_AUD" "DMN_MTL"
## [1] "SML"     "VIS_MTL" "FPN_SML" "AUD"     "SAL"
selectVar(spls1.int.brain.win, comp = 2)$X$name # "CON_SMD" "SML_REW" "DMN_MTL" "CON"     "SAL_AUD"
## [1] "DMN_VIS" "FPN_REW" "DMN_MTL" "DMN_SML" "DAN_PMN"
# what proportion of variance in microbiome is explained by each component
spls1.int.brain.win$prop_expl_var$X #3% explained by comp 1, 3% by comp 2
##      comp1      comp2 
## 0.02955026 0.03097805
spls1.int.brain.win$prop_expl_var$Y
##     comp1     comp2 
## 1.0000000 0.7148998
# plots of the results
plot(spls1.int.brain.win$variates$X, spls1.int.brain.win$variates$Y,
     xlab = 'X component', ylab = 'y component / scaled y') #

cor(spls1.int.brain.win$variates$X, spls1.int.brain.win$variates$Y) #comp1 x and y are correlated at .49, comp2 at .61
##           comp1        comp2
## comp1 0.5339478 1.829537e-16
## comp2 0.4165317 4.926352e-01
# extract component scores
brain.int.win.comp_scores <- as.data.frame(spls1.int.brain.win$variates$X) %>% 
  dplyr::rename(brain_int_win_comp1 = comp1,
                brain_int_win_comp2 = comp2) %>% 
  rownames_to_column(var="subID")

# save the loadings and vips, combining component 1 and component 2
brain_loadings <- selectVar(spls1.int.brain.win, comp=1)$X$value %>% rownames_to_column(var = "network") 
colnames(brain_loadings) <- c("network", "loading")
brain_vip<- as.data.frame(vip(spls1.int.brain.win)[selectVar(spls1.int.brain.win, comp=1)$X$name, 1]) %>% rownames_to_column(var="network")
colnames(brain_vip) <- c("network", "vip")

brain_load_vip_c1 <- brain_loadings %>% left_join(brain_vip, by = "network") %>% dplyr::mutate(loading = signif(loading, 2), vip = signif(vip, 2), signature = "SOFA Intra-Network")

brain_loadings_c2 <- selectVar(spls1.int.brain.win, comp=2)$X$value %>% rownames_to_column(var = "network") 
colnames(brain_loadings_c2) <- c("network", "loading")

brain_vip_c2 <- as.data.frame(vip(spls1.int.brain.win)[selectVar(spls1.int.brain.win, comp=2)$X$name, 2]) %>% rownames_to_column(var="network")
colnames(brain_vip_c2) <- c("network", "vip")

brain_load_vip_c2 <- brain_loadings_c2 %>% left_join(brain_vip_c2, by = "network") %>% dplyr::mutate(loading = signif(loading, 2), vip = signif(vip, 2), signature = "SOFA Inter-Network")

brain_load_vip_comb <- brain_load_vip_c1 %>% bind_rows(brain_load_vip_c2) %>% dplyr::select(network, signature, everything()) 

write_csv(brain_load_vip_comb, "tables_demo/TableS1.csv")

Plot Final Brain –> Internalizing Symptoms sPLS Model Loadings

3 networks with VIP above 1 for component 1 (SOFA Intra-Network), 5 networks with VIP above 1 in component 2 (SOFA Inter-Network)

brain.int.win_loadings_c1 <- selectVar(spls1.int.brain.win, comp=1)$X$value %>% rownames_to_column(var = "network")
colnames(brain.int.win_loadings_c1)[2] <- "loading_C1"

brain.int.win_loadings_c2 <- selectVar(spls1.int.brain.win, comp=2)$X$value %>% rownames_to_column(var = "network")
colnames(brain.int.win_loadings_c2)[2] <- "loading_C2"

# plot loadings using dataframes for the added flexibility of ggplot
# create a factor that sorts the loadings by magnitude 
brain.int.win_loadings_c1$network <- factor(brain.int.win_loadings_c1$network, levels = brain.int.win_loadings_c1$network[order(brain.int.win_loadings_c1$loading_C1, decreasing = TRUE)])

brain.int.win_loadings_c2$network <- factor(brain.int.win_loadings_c2$network, levels = brain.int.win_loadings_c2$network[order(brain.int.win_loadings_c2$loading_C2, decreasing = TRUE)])

# wherever there is "REW", replace with "SOFA" (more accurate name actually used in Seitzman 2020)
brain.int.win_loadings_c1$network <- str_replace(brain.int.win_loadings_c1$network, "REW", "SOFA")
brain.int.win_loadings_c2$network <- str_replace(brain.int.win_loadings_c2$network, "REW", "SOFA")

# graph the 10 highest loadings by magnitude, with vip > 1
brain_c1 <- ggplot(brain.int.win_loadings_c1 %>% slice_max(., n=3, order_by=abs(loading_C1)), aes(x = reorder(network, loading_C1), y = loading_C1)) +
  geom_col(fill = '#95cacb') + 
  coord_flip() +
  ylab("Loading") + xlab("Brain Network") +
  labs(tag = "A") + 
  theme_bw() +
  theme(axis.text.x = element_text(color="black", size=14), axis.text.y = element_text(color="black", size=14), axis.title = element_text(size=14), plot.tag=element_text(size=14)) +
  ggtitle("SOFA, MTL, SAL Intra-
  Network Signature") +
  theme(plot.title = element_text(hjust=0.5, size=14, face='bold'))

# graph comp2 loadings iwth vip > 1
brain_c2 <- ggplot(brain.int.win_loadings_c2 %>% slice_max(., n=5, order_by=abs(loading_C2)), aes(x = reorder(network, loading_C2), y = loading_C2)) +
  geom_col(fill = '#fd988d') + 
  coord_flip() +
  ylab("Loading") + xlab("Brain Network") +
  labs(tag = "C") + 
  theme_bw() +
  theme(axis.text.x = element_text(color="black", size=14), axis.text.y = element_text(color="black", size=14), axis.title = element_text(size=14), plot.tag=element_text(size=14)) +
  ggtitle("SOFA Inter-Network 
  Signature") +
  theme(plot.title = element_text(hjust=0.5, size=14, face='bold'))

# use patchwork package to arrange the plots next to each other
brain_c1 + brain_c2

ggsave('figures_demo/Figure1.png', brain_c1 + brain_c2, width = 9, height=5, dpi=1000)

Get brain network means, variances, and range

# calculate means and sds 
brain_means <- brain_cbcl_win_noids %>% 
  summarise_all(mean)

brain_sds <- brain_cbcl_win_noids %>% 
  summarise_all(sd)

brain_mins <- brain_cbcl_win_noids %>% 
  summarise_all(min)

brain_maxes <- brain_cbcl_win_noids %>% 
  summarise_all(max)

# reshape the dataframe
means <- brain_means %>% pivot_longer(
  cols = everything(),
  names_to = 'network',
  values_to = 'mean'
)

sds <- brain_sds %>% pivot_longer(
  cols = everything(),
  names_to = 'network',
  values_to = 'sd'
) 

mins <- brain_mins %>% pivot_longer(
  cols = everything(),
  names_to = 'network',
  values_to = 'min'
) 

maxes <- brain_maxes %>% pivot_longer(
  cols = everything(),
  names_to = 'network',
  values_to = 'max'
) 

summary <- means %>% full_join(sds, by = "network") %>% full_join(mins, by = "network") %>% full_join(maxes, by = "network")

write_csv(summary, "tables_demo/brain_network_descriptives.csv")

Covariate Selection

Now that we have the brain signature component scores, we can do covariate selection for the regression models. a-priori covariates: sex, gestational age, birthweight, mean FD, delivery mode Selection is on diet covariates ### Look at correlations between covariates

# merge component scores with rest of dataset
metadata_comp <- cbcl_comp_dataset %>% left_join(brain.int.win.comp_scores, by = "subID") 

# select out the diet variables for the correlation matrix
diet <- cbcl_comp_dataset %>% 
  dplyr::select(subID, `Protein_%energy`:DQI.score.adjusted)
  
# correlations between diet covariates
diet_m <- diet %>% dplyr::select(-subID)
testRes = cor.mtest(diet_m, conf.level = 0.95)
M = cor(diet_m)
corrplot(M, p.mat = testRes$p, sig.level = 0.05, order = 'hclust', addrect = 2)

# because these are randomly generated values, there aren't substantial correlations in this simulated dataset

# correlation with brain component scores and alpha div
diet_omics_m <- metadata_comp %>% 
  dplyr::select(
  "SOFA, MTL, SAL Intra-Network Signature" = brain_int_win_comp1,
  "SOFA Inter-Network Signature" = brain_int_win_comp2,
  "Internalizing Symptoms" = cbclintprobtot_y7,
  "Shannon Index" = shannon_entropy,
  "Observed Features" = observed_features,
  "Pielou Evenness" = pielou_evenness,
  "Faith's PD" = faith_pd,
  "Protein" = `Protein_%energy`,
  "Total Fat" = `Fat_%energy`,
  "Carbs" = `CHO_%energy`,
  "Fiber" = Fibre.per.1000kcal,
  "Saturated Fat" = `SatFat_%`,
  "MUFA" = `MUFA_%`,
  "PUFA" = `PUFA_%`
) %>% drop_na() 

testRes1 = cor.mtest(diet_omics_m, conf.level = 0.95)
M1 = cor(diet_omics_m)
# only significant association with alpha div is fiber + related to shannon entropy and observed features, brain comp2 is - related to fat % energy and + related to cho % energy, internalizing is + related to PUFA

corrplot(M1,
         method="color",
         type="lower",
         diag=TRUE,
         p.mat = testRes1$p,
         insig = "label_sig",
         sig.level = c(.001, .01, .05),
         pch.cex = 0.8,
         pch.col = "yellow",
         tl.col="black",
         tl.cex=0.8,
         addCoef.col = "black",
         tl.pos="l",
         cl.pos="r",
         outline=TRUE) 

# can't figure out how to save this besides taking a picture of output

# significant correlations in corrplot with real dataset that I wanted to output the exact value of:
cor.test(diet_m$`Fat_%energy`, diet_m$Fibre.per.1000kcal) 
## 
##  Pearson's product-moment correlation
## 
## data:  x and y
## t = -1.0746, df = 53, p-value = 0.2874
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3959848  0.1240756
## sample estimates:
##        cor 
## -0.1460284
cor.test(diet_m$`Fat_%energy`, diet_m$`CHO_%energy`) 
## 
##  Pearson's product-moment correlation
## 
## data:  x and y
## t = -0.85743, df = 53, p-value = 0.3951
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3707609  0.1530784
## sample estimates:
##        cor 
## -0.1169691
cor.test(diet_m$`Fat_%energy`, diet_m$`PUFA_%`) 
## 
##  Pearson's product-moment correlation
## 
## data:  x and y
## t = 0.62051, df = 53, p-value = 0.5376
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1845295  0.3425056
## sample estimates:
##       cor 
## 0.0849252
cor.test(diet_m$Fibre.per.1000kcal, diet_m$`PUFA_%`) 
## 
##  Pearson's product-moment correlation
## 
## data:  x and y
## t = -0.53042, df = 53, p-value = 0.598
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3315716  0.1964173
## sample estimates:
##         cor 
## -0.07266648
# make bf into ordered factor
metadata_comp$any_bf_months <- factor(metadata_comp$any_bf_months, levels = c("1M_to_3M", "3M_to_6M", "6M_to_12M", ">12M"))

# breastfeeding associations with brain/int components, internalizing, or alpha diversity: anovas
summary(aov(brain_int_win_comp1~any_bf_months, data=metadata_comp)) 
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3   3.79   1.264   0.972  0.416
## Residuals     38  49.40   1.300               
## 13 observations deleted due to missingness
summary(aov(brain_int_win_comp2~any_bf_months, data=metadata_comp)) #ns
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3   1.72  0.5746   0.352  0.788
## Residuals     38  62.04  1.6327               
## 13 observations deleted due to missingness
summary(aov(cbclintprobtot_y7~any_bf_months, data=metadata_comp)) #ns
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3   15.2   5.061   0.201  0.895
## Residuals     38  956.7  25.177               
## 13 observations deleted due to missingness
summary(aov(shannon_entropy~any_bf_months, data=metadata_comp))
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3  2.176  0.7252   1.144  0.344
## Residuals     38 24.089  0.6339               
## 13 observations deleted due to missingness
summary(aov(observed_features~any_bf_months, data=metadata_comp))
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3   1458   485.9   0.824  0.489
## Residuals     38  22401   589.5               
## 13 observations deleted due to missingness
summary(aov(pielou_evenness~any_bf_months, data=metadata_comp))
##               Df Sum Sq  Mean Sq F value Pr(>F)
## any_bf_months  3 0.0041 0.001377   0.149   0.93
## Residuals     38 0.3505 0.009222               
## 13 observations deleted due to missingness
summary(aov(faith_pd~any_bf_months, data=metadata_comp))
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3  10.53   3.510   1.229  0.313
## Residuals     38 108.55   2.857               
## 13 observations deleted due to missingness
# is breastfeeding correlated with any diet vars we have selecte?
summary(aov(`PUFA_%`~any_bf_months, data=metadata_comp)) # 
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3    997   332.5   1.499   0.23
## Residuals     38   8430   221.8               
## 13 observations deleted due to missingness
summary(aov(`Fat_%energy`~any_bf_months, data=metadata_comp)) 
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3   29.5    9.82   0.207  0.891
## Residuals     38 1801.1   47.40               
## 13 observations deleted due to missingness
summary(aov(Fibre.per.1000kcal  ~any_bf_months, data=metadata_comp)) 
##               Df Sum Sq Mean Sq F value Pr(>F)
## any_bf_months  3   17.0   5.655   0.641  0.593
## Residuals     38  335.2   8.821               
## 13 observations deleted due to missingness
# birth method associations with brain/int components, internalizing, or alpha diversity: t-tests
t.test(metadata_comp$deliv_mode, metadata_comp$brain_int_win_comp1) #
## 
##  Welch Two Sample t-test
## 
## data:  metadata_comp$deliv_mode and metadata_comp$brain_int_win_comp1
## t = 2.0058, df = 72.913, p-value = 0.04859
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.002084096 0.652461359
## sample estimates:
##    mean of x    mean of y 
## 3.272727e-01 1.750868e-16
t.test(metadata_comp$deliv_mode, metadata_comp$brain_int_win_comp1)
## 
##  Welch Two Sample t-test
## 
## data:  metadata_comp$deliv_mode and metadata_comp$brain_int_win_comp1
## t = 2.0058, df = 72.913, p-value = 0.04859
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.002084096 0.652461359
## sample estimates:
##    mean of x    mean of y 
## 3.272727e-01 1.750868e-16
t.test(metadata_comp$deliv_mode, metadata_comp$cbclintprobtot_y7) #  
## 
##  Welch Two Sample t-test
## 
## data:  metadata_comp$deliv_mode and metadata_comp$cbclintprobtot_y7
## t = -8.1068, df = 55.12, p-value = 5.757e-11
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -6.372029 -3.846153
## sample estimates:
## mean of x mean of y 
## 0.3272727 5.4363636
# is birth method associated with any diet vars we have selected?
t.test(metadata_comp$deliv_mode, metadata_comp$`PUFA_%`)
## 
##  Welch Two Sample t-test
## 
## data:  metadata_comp$deliv_mode and metadata_comp$`PUFA_%`
## t = -16.832, df = 54.11, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -37.62320 -29.61476
## sample estimates:
##  mean of x  mean of y 
##  0.3272727 33.9462514
# how many infants are in each breastfeeding category?
metadata_comp %>% dplyr::filter(!is.na(cbclintprobtot_y7)) %>% dplyr::count(any_bf_months) #
## # A tibble: 5 × 2
##   any_bf_months     n
##   <fct>         <int>
## 1 1M_to_3M          6
## 2 3M_to_6M         11
## 3 6M_to_12M        14
## 4 >12M             11
## 5 <NA>             13
# is GA and BW related to each other?
cor.test(metadata_comp$GA_centered, metadata_comp$BW_centered) 
## 
##  Pearson's product-moment correlation
## 
## data:  x and y
## t = 0.6936, df = 53, p-value = 0.491
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1748529  0.3513017
## sample estimates:
##        cor 
## 0.09484393
# we want to add diet covariates to the regression with brain and internalizing, bc 1) Fat is related to brain and PUFA is related to internalizing, 2) we want to keep largely same covariate set for each analysis

Missing data rates for covariates

For the simulated dataset, there are no missing values for covariates, but there are in the real dataset and this code determines the rates.

# count number missing on each covariate: ga, bw, sex, delivery mode, diet, breastfeeding
cbcl_comp_dataset %>% dplyr::count(is.na(sex_centered)) # complete
## # A tibble: 1 × 2
##   `is.na(sex_centered)`     n
##   <lgl>                 <int>
## 1 FALSE                    55
cbcl_comp_dataset %>% dplyr::count(is.na(GA_centered)) # complete
## # A tibble: 1 × 2
##   `is.na(GA_centered)`     n
##   <lgl>                <int>
## 1 FALSE                   55
cbcl_comp_dataset %>% dplyr::count(is.na(BW_centered)) # complete
## # A tibble: 1 × 2
##   `is.na(BW_centered)`     n
##   <lgl>                <int>
## 1 FALSE                   55
cbcl_comp_dataset %>% dplyr::count(is.na(deliv_mode)) # complete
## # A tibble: 1 × 2
##   `is.na(deliv_mode)`     n
##   <lgl>               <int>
## 1 FALSE                  55
cbcl_comp_dataset %>% group_by(is.na(Fibre.per.1000kcal)) %>% summarise(n = n()) %>%
  mutate(freq = n / sum(n)) 
## # A tibble: 1 × 3
##   `is.na(Fibre.per.1000kcal)`     n  freq
##   <lgl>                       <int> <dbl>
## 1 FALSE                          55     1
cbcl_comp_dataset %>% dplyr::count(is.na(any_bf_months))
## # A tibble: 1 × 2
##   `is.na(any_bf_months)`     n
##   <lgl>                  <int>
## 1 FALSE                     55

Brain Signatures –> Internalizing Regression Models

Transform the internalizing symptom outcome variable for linear regression

Box-cox transformation in R: https://www.r-bloggers.com/2022/10/box-cox-transformation-in-r/

# distribution of component scores (comments are about their distributions in real dataset, for illustration of decision-making)
gf_histogram(~metadata_comp$brain_int_win_comp1, bins=15) #normal enough

gf_histogram(~metadata_comp$brain_int_win_comp2, bins=15) #a bit skewed

gf_histogram(~metadata_comp$cbclintprobtot_y7) # skewed; do box-cox transformation 

# box-cox transformation on intprob (add constant of 1 to all values to make it positive, required for box-cox)
metadata_comp <- metadata_comp %>% dplyr::mutate(cbclintprobtot_y7_pos = cbclintprobtot_y7+1)
# extract optimal lambda 
boxcox(lm(metadata_comp$cbclintprobtot_y7_pos ~ 1),
       lambda = seq(-2, 2, 1/10), 
       plotit = TRUE,  
       eps = 1/50,     
       xlab = expression(lambda), 
       ylab = "log-Likelihood",   
       ) #95% CI is roughly 0 to 0.5

b <- boxcox(lm(metadata_comp$cbclintprobtot_y7_pos ~ 1),
       lambda = seq(-2, 2, 1/10), 
       plotit = TRUE,  
       eps = 1/50,     
       xlab = expression(lambda), 
       ylab = "log-Likelihood",   
       )

lambda <- b$x[which.max(b$y)] # lambda = 0.26
 
# apply the transformation 
metadata_comp <- metadata_comp %>%
  dplyr::mutate(
    cbclintprobtot_y7_pos_boxcox = (cbclintprobtot_y7_pos ^ lambda- 1)/lambda 
  )

#graph transformed varaible
gf_histogram(~metadata_comp$cbclintprobtot_y7_pos_boxcox) #looks somewhat better

Brain Signatures –> Internalizing Regression Models, controlling for selected covariates

# regression with comp scores predicting internalizing, controlling for covariates
comp1_int_trans_diet <- lm(cbclintprobtot_y7_pos_boxcox ~ brain_int_win_comp1 + sex_centered + BW_centered + deliv_mode + `PUFA_%` + `Fat_%energy` + meanFD_centered, data=metadata_comp)
tab_model(comp1_int_trans_diet, robust=TRUE, show.std=TRUE, show.se=TRUE) # comp1 is positively related to internalizing (in real dataset)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 1.59 0.86 0.00 0.13 -0.13 – 3.31 -0.26 – 0.26 0.070
brain int win comp1 0.52 0.15 0.48 0.14 0.22 – 0.82 0.20 – 0.75 0.001
sex centered 0.14 0.18 0.11 0.14 -0.22 – 0.51 -0.17 – 0.40 0.424
BW centered -0.00 0.45 -0.00 0.13 -0.90 – 0.90 -0.27 – 0.27 0.994
deliv mode -0.25 0.36 -0.10 0.14 -0.98 – 0.47 -0.38 – 0.18 0.483
PUFA % 0.02 0.01 0.19 0.14 -0.01 – 0.04 -0.08 – 0.46 0.170
Fat %energy -0.00 0.02 -0.01 0.13 -0.05 – 0.05 -0.27 – 0.26 0.964
meanFD centered -4.61 5.25 -0.11 0.12 -15.17 – 5.96 -0.36 – 0.14 0.385
Observations 55
R2 / R2 adjusted 0.314 / 0.212
comp2_int_trans <- lm(cbclintprobtot_y7_pos_boxcox ~ brain_int_win_comp2 + sex_centered + GA_centered + BW_centered + deliv_mode + `PUFA_%` + `Fat_%energy` + meanFD_centered, data=metadata_comp)
tab_model(comp2_int_trans, robust=TRUE, show.std=TRUE, show.se=TRUE) # comp2 is positively related to internalizing (in real dataset)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 1.58 0.59 0.00 0.13 0.40 – 2.76 -0.26 – 0.26 0.010
brain int win comp2 0.51 0.12 0.48 0.12 0.26 – 0.76 0.25 – 0.71 <0.001
sex centered 0.17 0.19 0.14 0.15 -0.22 – 0.56 -0.17 – 0.44 0.378
GA centered 0.06 0.15 0.05 0.13 -0.25 – 0.37 -0.21 – 0.31 0.700
BW centered -0.16 0.46 -0.05 0.14 -1.09 – 0.77 -0.32 – 0.23 0.726
deliv mode -0.53 0.38 -0.20 0.15 -1.29 – 0.23 -0.50 – 0.09 0.169
PUFA % 0.02 0.01 0.20 0.11 -0.00 – 0.03 -0.01 – 0.41 0.065
Fat %energy 0.00 0.02 0.01 0.10 -0.03 – 0.04 -0.19 – 0.20 0.952
meanFD centered -2.14 4.98 -0.05 0.12 -12.16 – 7.88 -0.29 – 0.19 0.669
Observations 55
R2 / R2 adjusted 0.326 / 0.209

Identification of Microbiome Asosciations with Brain Signatures

Microbiome Profiles and Alpha Diversity

Alpha Diversity

Alpha diversity + covs ~ brain comps

# shannon
shannon_comp1 <- lm(brain_int_win_comp1 ~ shannon_entropy + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)
#assumptions for comp1 models (will look similar for other metrics bc alpha divs are all pretty normally distributed)
shannon_comp1_resids <- resid(shannon_comp1)
shannon_comp1_fitted <- fitted(shannon_comp1)
##normality of residuals
hist(shannon_comp1_resids) # relatively normal, a little bit sparse upper part of distributino

##heteroskedasticity + linearity
plot(shannon_comp1_resids ~ shannon_comp1_fitted) #

tab_model(shannon_comp1, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns
  brain int win comp 1
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) -0.06 1.14 -0.00 0.16 -2.35 – 2.23 -0.32 – 0.32 0.957
shannon entropy -0.00 0.27 -0.00 0.19 -0.55 – 0.55 -0.38 – 0.38 0.999
sex centered 0.13 0.22 0.11 0.19 -0.31 – 0.57 -0.27 – 0.50 0.558
GA centered 0.20 0.18 0.19 0.16 -0.15 – 0.55 -0.14 – 0.52 0.259
BW centered -0.19 0.61 -0.06 0.20 -1.42 – 1.04 -0.46 – 0.34 0.759
deliv mode -0.17 0.41 -0.07 0.17 -0.99 – 0.65 -0.42 – 0.28 0.674
Fat %energy 0.01 0.03 0.04 0.21 -0.06 – 0.08 -0.39 – 0.47 0.849
Fibre per 1000kcal -0.02 0.06 -0.06 0.16 -0.14 – 0.10 -0.38 – 0.26 0.705
meanFD centered 5.60 7.04 0.15 0.18 -8.57 – 19.76 -0.22 – 0.51 0.430
Observations 55
R2 / R2 adjusted 0.080 / -0.080
shannon_comp1_ncov <- lm(brain_int_win_comp1 ~ shannon_entropy, data = metadata_comp)
tab_model(shannon_comp1_ncov, robust=TRUE, show.std=TRUE) #ns
  brain int win comp 1
Predictors Estimates std. Beta CI standardized CI p
(Intercept) -0.09 -0.00 -1.53 – 1.35 -0.28 – 0.28 0.902
shannon entropy 0.03 0.02 -0.43 – 0.48 -0.30 – 0.34 0.900
Observations 55
R2 / R2 adjusted 0.000 / -0.018
shannon_comp2 <- lm(brain_int_win_comp2 ~ shannon_entropy + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)

#assumptions for comp2 models (will look similar for other metrics bc alpha divs are all pretty normally distributed)
shannon_comp2_resids <- resid(shannon_comp2)
shannon_comp2_fitted <- fitted(shannon_comp2)
##normality of residuals
hist(shannon_comp2_resids) # pretty normal

##heteroskedasticity + linearity
plot(shannon_comp2_resids ~ shannon_comp2_fitted) # 

tab_model(shannon_comp2, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns in real dataset
  brain int win comp 2
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) -1.04 0.97 0.00 0.16 -2.99 – 0.91 -0.31 – 0.31 0.290
shannon entropy 0.15 0.37 0.10 0.25 -0.61 – 0.90 -0.41 – 0.61 0.697
sex centered -0.02 0.22 -0.01 0.18 -0.46 – 0.42 -0.38 – 0.36 0.940
GA centered 0.02 0.18 0.02 0.16 -0.35 – 0.38 -0.31 – 0.34 0.926
BW centered 0.19 0.45 0.06 0.14 -0.72 – 1.09 -0.23 – 0.34 0.679
deliv mode 0.40 0.48 0.16 0.20 -0.57 – 1.37 -0.23 – 0.56 0.412
Fat %energy 0.00 0.03 0.01 0.20 -0.07 – 0.07 -0.39 – 0.42 0.955
Fibre per 1000kcal 0.06 0.07 0.17 0.18 -0.07 – 0.20 -0.20 – 0.53 0.357
meanFD centered 1.71 6.20 0.04 0.16 -10.77 – 14.20 -0.27 – 0.36 0.784
Observations 55
R2 / R2 adjusted 0.069 / -0.093
shannon_comp2_ncov <- lm(brain_int_win_comp2 ~ shannon_entropy, data = metadata_comp)
tab_model(shannon_comp2_ncov, robust=TRUE, show.std=TRUE) #ns in real dataset
  brain int win comp 2
Predictors Estimates std. Beta CI standardized CI p
(Intercept) -0.67 0.00 -2.33 – 1.00 -0.28 – 0.28 0.425
shannon entropy 0.21 0.14 -0.28 – 0.71 -0.19 – 0.48 0.390
Observations 55
R2 / R2 adjusted 0.021 / 0.003
# observed features
feat_comp1 <- lm(brain_int_win_comp1 ~ observed_features + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)
tab_model(feat_comp1, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns in real dataset
  brain int win comp 1
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 0.65 1.23 -0.00 0.16 -1.82 – 3.12 -0.31 – 0.31 0.598
observed features -0.01 0.01 -0.17 0.17 -0.02 – 0.01 -0.52 – 0.17 0.318
sex centered 0.14 0.21 0.12 0.18 -0.28 – 0.56 -0.24 – 0.49 0.505
GA centered 0.20 0.17 0.19 0.16 -0.14 – 0.54 -0.13 – 0.50 0.249
BW centered -0.20 0.62 -0.06 0.20 -1.44 – 1.04 -0.47 – 0.34 0.751
deliv mode -0.11 0.41 -0.05 0.17 -0.93 – 0.70 -0.40 – 0.30 0.779
Fat %energy 0.01 0.03 0.03 0.19 -0.06 – 0.07 -0.36 – 0.42 0.860
Fibre per 1000kcal -0.03 0.06 -0.07 0.17 -0.15 – 0.10 -0.41 – 0.26 0.655
meanFD centered 7.48 7.20 0.19 0.19 -7.01 – 21.97 -0.18 – 0.57 0.304
Observations 55
R2 / R2 adjusted 0.107 / -0.048
feat_comp1_ncovs <- lm(brain_int_win_comp1 ~ observed_features, data = metadata_comp)
tab_model(feat_comp1_ncovs, robust=TRUE, show.std=TRUE) #ns in real dataset
  brain int win comp 1
Predictors Estimates std. Beta CI standardized CI p
(Intercept) 0.42 -0.00 -0.74 – 1.58 -0.28 – 0.28 0.474
observed features -0.01 -0.11 -0.02 – 0.01 -0.40 – 0.18 0.458
Observations 55
R2 / R2 adjusted 0.012 / -0.007
feat_comp2 <- lm(brain_int_win_comp2 ~ observed_features + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)
tab_model(feat_comp2, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns in real dataset
  brain int win comp 2
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) -2.17 0.92 0.00 0.15 -4.03 – -0.31 -0.29 – 0.29 0.023
observed features 0.01 0.01 0.31 0.15 0.00 – 0.03 0.02 – 0.60 0.038
sex centered -0.01 0.20 -0.01 0.17 -0.43 – 0.40 -0.36 – 0.34 0.948
GA centered 0.02 0.15 0.02 0.14 -0.29 – 0.32 -0.26 – 0.29 0.904
BW centered 0.19 0.44 0.06 0.14 -0.70 – 1.08 -0.22 – 0.34 0.675
deliv mode 0.32 0.44 0.13 0.18 -0.56 – 1.20 -0.23 – 0.49 0.468
Fat %energy 0.01 0.02 0.06 0.13 -0.03 – 0.05 -0.20 – 0.32 0.644
Fibre per 1000kcal 0.08 0.06 0.22 0.15 -0.03 – 0.20 -0.09 – 0.53 0.156
meanFD centered -1.48 6.10 -0.04 0.15 -13.75 – 10.80 -0.34 – 0.27 0.810
Observations 55
R2 / R2 adjusted 0.148 / -0.001
feat_comp2_ncovs <- lm(brain_int_win_comp2 ~ observed_features, data = metadata_comp)
tab_model(feat_comp2_ncovs, robust=TRUE, show.std=TRUE) #ns in real dataset
  brain int win comp 2
Predictors Estimates std. Beta CI standardized CI p
(Intercept) -1.15 0.00 -2.09 – -0.20 -0.26 – 0.26 0.018
observed features 0.01 0.29 0.00 – 0.02 0.07 – 0.51 0.011
Observations 55
R2 / R2 adjusted 0.085 / 0.067
# faith pd
faith_comp1 <- lm(brain_int_win_comp1 ~ faith_pd + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)
tab_model(faith_comp1, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns
  brain int win comp 1
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 0.50 1.04 0.00 0.15 -1.60 – 2.59 -0.30 – 0.30 0.636
faith pd -0.24 0.13 -0.38 0.20 -0.50 – 0.02 -0.78 – 0.03 0.067
sex centered 0.03 0.21 0.02 0.18 -0.39 – 0.44 -0.34 – 0.39 0.902
GA centered 0.29 0.17 0.27 0.16 -0.06 – 0.64 -0.06 – 0.60 0.104
BW centered -0.43 0.60 -0.14 0.20 -1.65 – 0.78 -0.54 – 0.25 0.475
deliv mode -0.43 0.41 -0.18 0.17 -1.25 – 0.39 -0.53 – 0.16 0.295
Fat %energy 0.02 0.04 0.12 0.22 -0.05 – 0.09 -0.31 – 0.56 0.570
Fibre per 1000kcal 0.04 0.07 0.12 0.19 -0.09 – 0.18 -0.25 – 0.50 0.520
meanFD centered 5.01 6.22 0.13 0.16 -7.52 – 17.53 -0.20 – 0.45 0.425
Observations 55
R2 / R2 adjusted 0.167 / 0.022
faith_comp1_ncovs <- lm(brain_int_win_comp1 ~ faith_pd, data = metadata_comp)
tab_model(faith_comp1_ncovs, robust=TRUE, show.std=TRUE) #ns
  brain int win comp 1
Predictors Estimates std. Beta CI standardized CI p
(Intercept) 0.76 -0.00 -0.26 – 1.78 -0.27 – 0.27 0.143
faith pd -0.14 -0.22 -0.32 – 0.03 -0.49 – 0.05 0.106
Observations 55
R2 / R2 adjusted 0.049 / 0.031
faith_comp2 <- lm(brain_int_win_comp2 ~ faith_pd + sex_centered + GA_centered + BW_centered + deliv_mode +`Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)
tab_model(faith_comp2, robust=TRUE, show.std=TRUE, show.se=TRUE) #sig, higher faith with higher comp2 (in real dataset) scores (beta = .38, p=.004)
  brain int win comp 2
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) -0.73 1.04 0.00 0.15 -2.82 – 1.36 -0.31 – 0.31 0.484
faith pd -0.05 0.15 -0.07 0.23 -0.35 – 0.26 -0.54 – 0.39 0.746
sex centered -0.01 0.25 -0.01 0.21 -0.51 – 0.48 -0.43 – 0.40 0.952
GA centered 0.03 0.17 0.03 0.15 -0.31 – 0.37 -0.28 – 0.33 0.857
BW centered 0.12 0.51 0.04 0.16 -0.91 – 1.15 -0.29 – 0.36 0.812
deliv mode 0.37 0.46 0.15 0.19 -0.54 – 1.29 -0.22 – 0.53 0.417
Fat %energy 0.01 0.02 0.07 0.14 -0.04 – 0.06 -0.22 – 0.35 0.652
Fibre per 1000kcal 0.09 0.08 0.23 0.22 -0.08 – 0.25 -0.20 – 0.67 0.291
meanFD centered 1.89 6.07 0.05 0.15 -10.33 – 14.11 -0.26 – 0.35 0.757
Observations 55
R2 / R2 adjusted 0.065 / -0.098
faith_comp2_ncovs <- lm(brain_int_win_comp2 ~ faith_pd, data = metadata_comp)
tab_model(faith_comp2_ncovs, robust=TRUE, show.std=TRUE) #sig, same as with covariates (in real dataset)
  brain int win comp 2
Predictors Estimates std. Beta CI standardized CI p
(Intercept) 0.03 -0.00 -1.18 – 1.23 -0.28 – 0.28 0.966
faith pd -0.00 -0.01 -0.22 – 0.21 -0.33 – 0.32 0.964
Observations 55
R2 / R2 adjusted 0.000 / -0.019
# evenness
even_comp1 <- lm(brain_int_win_comp1 ~ pielou_evenness + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)
tab_model(even_comp1, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns
  brain int win comp 1
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 0.08 1.37 -0.00 0.16 -2.67 – 2.83 -0.32 – 0.32 0.955
pielou evenness -0.32 1.84 -0.03 0.15 -4.03 – 3.38 -0.34 – 0.28 0.861
sex centered 0.13 0.20 0.11 0.18 -0.28 – 0.54 -0.25 – 0.47 0.525
GA centered 0.20 0.17 0.19 0.16 -0.14 – 0.54 -0.13 – 0.51 0.234
BW centered -0.20 0.61 -0.06 0.20 -1.43 – 1.04 -0.47 – 0.34 0.749
deliv mode -0.18 0.39 -0.08 0.17 -0.97 – 0.61 -0.41 – 0.26 0.646
Fat %energy 0.01 0.03 0.05 0.20 -0.06 – 0.07 -0.35 – 0.45 0.811
Fibre per 1000kcal -0.02 0.06 -0.06 0.17 -0.15 – 0.10 -0.40 – 0.27 0.701
meanFD centered 5.55 7.13 0.14 0.19 -8.80 – 19.91 -0.23 – 0.52 0.440
Observations 55
R2 / R2 adjusted 0.081 / -0.079
even_comp1_ncovs <- lm(brain_int_win_comp1 ~ pielou_evenness, data = metadata_comp)
tab_model(even_comp1_ncovs, robust=TRUE, show.std=TRUE) #ns
  brain int win comp 1
Predictors Estimates std. Beta CI standardized CI p
(Intercept) -0.08 -0.00 -1.78 – 1.62 -0.28 – 0.28 0.923
pielou evenness 0.16 0.01 -3.25 – 3.57 -0.27 – 0.30 0.925
Observations 55
R2 / R2 adjusted 0.000 / -0.019
even_comp2 <- lm(brain_int_win_comp2 ~ pielou_evenness + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = metadata_comp)
tab_model(even_comp2, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns
  brain int win comp 2
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) -1.06 1.38 0.00 0.15 -3.83 – 1.71 -0.31 – 0.31 0.446
pielou evenness 0.50 2.01 0.04 0.16 -3.55 – 4.54 -0.29 – 0.37 0.807
sex centered 0.00 0.22 0.00 0.19 -0.45 – 0.45 -0.37 – 0.38 0.985
GA centered 0.01 0.17 0.01 0.15 -0.34 – 0.35 -0.30 – 0.32 0.965
BW centered 0.19 0.46 0.06 0.14 -0.73 – 1.10 -0.23 – 0.35 0.684
deliv mode 0.44 0.44 0.18 0.18 -0.45 – 1.32 -0.18 – 0.54 0.322
Fat %energy 0.01 0.02 0.04 0.14 -0.04 – 0.05 -0.24 – 0.31 0.781
Fibre per 1000kcal 0.08 0.07 0.20 0.17 -0.06 – 0.21 -0.14 – 0.54 0.250
meanFD centered 2.08 6.13 0.05 0.15 -10.26 – 14.41 -0.26 – 0.36 0.736
Observations 55
R2 / R2 adjusted 0.063 / -0.100
even_comp2_ncovs <- lm(brain_int_win_comp2 ~ pielou_evenness, data = metadata_comp)
tab_model(even_comp2_ncovs, robust=TRUE, show.std=TRUE) #ns
  brain int win comp 2
Predictors Estimates std. Beta CI standardized CI p
(Intercept) -0.04 -0.00 -1.85 – 1.78 -0.28 – 0.28 0.969
pielou evenness 0.07 0.01 -3.61 – 3.75 -0.29 – 0.30 0.970
Observations 55
R2 / R2 adjusted 0.000 / -0.019
# quick scatterplot of faith and brain comp2 (related in real dataset)
ggplot(metadata_comp, aes(faith_pd, brain_int_win_comp2)) +
  geom_jitter() +
  geom_smooth(method="lm")
## `geom_smooth()` using formula = 'y ~ x'

#note: did not remove or winsorize high outliers on Faith bc if you look in the full sample, it appears Faith has bimodal distribution (there is a smaller high group which is just very small in this subsample) 

Figure 2: Faith’s PD and SOFA Inter-Network Signature

We will residualize both x and y to represent a partial regression coefficient, which is what we get from a MLR controlling for covariates.

braincomp_faith <- metadata_comp %>% 
  filter(!is.na(sex_centered) & !is.na(GA_centered) &!is.na(BW_centered) &!is.na(deliv_mode) & !is.na(`Fat_%energy`) & !is.na(Fibre.per.1000kcal) & !is.na(meanFD_centered) & !is.na(cbclintprobtot_y7) & !is.na(faith_pd))

# residualize brain comp2 scores by covariates
braincomp2_resid <- lm(brain_int_win_comp2 ~sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = braincomp_faith)

# resiaulize faith by covariates
faith_resid <- lm(faith_pd ~sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + meanFD_centered, data = braincomp_faith)

braincomp_faith <- braincomp_faith %>% 
  mutate(
    braincomp2_resid = resid(braincomp2_resid),
    faith_braincomp2_resid = resid(faith_resid)
  ) 

# graph
ggplot(braincomp_faith, aes(faith_braincomp2_resid, braincomp2_resid)) +
  geom_point(position=position_jitter(w=0.3, h=0)) +
  geom_smooth(method="lm", fill = '#7570b3', color = '#7570b3') +
  ylab("SOFA Inter-Network \n Connectivity Brain Signature") + xlab("Faith's Phylogenetic Diversity") +
  theme_bw() +
  theme(axis.text.x = element_text(color="black", size=12), axis.text.y = element_text(color="black", size=12), axis.title = element_text(size=15)) 
## `geom_smooth()` using formula = 'y ~ x'

# save
ggsave("figures_demo/Figure4.jpg", width = 9, height=5, dpi=1000)
## `geom_smooth()` using formula = 'y ~ x'

Microbial Profile(s) with SOFA, MTL, SAL Intra-Network Signature

# grab mb ids with values for the brain-int compoment scores
mb_data_brainint <- metadata_comp %>% 
  dplyr::select(Actinomyces:Akkermansia) 
rownames(mb_data_brainint) <- metadata_comp$subID
## Warning: Setting row names on a tibble is deprecated.
# initial sPLS model (should specify a large number of components first)
tune.spls1.braincomp.mb <- pls(X=mb_data_brainint, Y=metadata_comp$brain_int_win_comp1, ncomp=4, mode='regression')

set.seed(main.seed)
R2.spls1.braincomp.mb <- perf(tune.spls1.braincomp.mb, validation='Mfold',
                           folds=10, nrepeat=50)

plot(R2.spls1.braincomp.mb, criterion = 'R2') # for demo dataset, best is 4 components but error bars overlap for 1-4

# we will test 2 components to be consistent with the real dataset

# evaluate number of variables to select from X matrix (using number of components selected above)
list.keepX <- c(5:10, seq(15, 64, 5)) # specify selection up to the number of features in the dataset (65)

# evaluate tuning w/ R^2 
set.seed(main.seed)
tune.spls1.braincomp.mb.R2 <- mixOmics::tune.spls(mb_data_brainint, metadata_comp$brain_int_win_comp1, ncomp= 2, 
                            test.keepX = list.keepX, 
                            validation = 'Mfold', 
                            folds = 10,
                            nrepeat = 100, 
                            progressBar = TRUE,
                            measure = 'R2') 
## 
## comp 1 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
## comp 2 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
plot(tune.spls1.braincomp.mb.R2) #highest R^2 (0.02) is with 2 component and 60 features. To be consistent with the real dataset, we will set 1 component with 15 features 

#how many components to keep w this?
choice.ncomp <- 1
# how many x variables with 1 component? 60
choice.keepX <- tune.spls1.braincomp.mb.R2$choice.keepX[1:1] #60
# but, we will set it manually to be consistent with real dataset
choice.keepX <- 15

# specify final model with 1 components, 15 features on comp1
spls1.braincomp.mb <- spls(X=mb_data_brainint, Y=brain.int.win.comp_scores$brain_int_win_comp1, ncomp = choice.ncomp, keepX = choice.keepX, mode = "regression")

# extract list of features that were selected (each component is orthogonal)
selectVar(spls1.braincomp.mb, comp = 1)$X$name #
##  [1] "Prevotella"          "Dialister"           "Faecalitalea"       
##  [4] "Ruminiclostridium"   "Peptoclostridium"    "Ruminiclostridium.5"
##  [7] "Actinomyces"         "Alistipes"           "Terrisporobacter"   
## [10] "Intestinibacter"     "Bacteroides"         "Hungatella"         
## [13] "Blautia"             "Enterococcus"        "NC2004"
plotLoadings(spls1.braincomp.mb, 'X') # 

plot(spls1.braincomp.mb$variates$X, spls1.braincomp.mb$variates$Y,
     xlab = 'X component', ylab = 'y component / scaled y') #

cor(spls1.braincomp.mb$variates$X, spls1.braincomp.mb$variates$Y) # cor = .65
##           comp1
## comp1 0.6128758
# there are no really stand-out outliers in the simulated dataset, but we will winsorize one value in order to be consistent w the steps taken in the real dataset
# extract component scores to investigate high outlier (G14)
mbXbraincomp_comp1 <- as.data.frame(spls1.braincomp.mb$variates$X) %>% 
  dplyr::rename(mb_braincomp_comp1 = comp1) %>% rownames_to_column(var = "subID")

mb_data_brainint %>% 
  rownames_to_column(var = "subID") %>% 
  pivot_longer(-subID) %>% #To make the data in long form required for `tidyverse`
  group_by(name) %>% #Based on which column you want aggregate 
  identify_outliers(value) %>% 
  select(name, subID, value, is.outlier, is.extreme) %>% # extreme = Q3 + 3*IQR, outlier = Q3 + 1.5*IQR
  #dplyr::filter(name %in% c("Eubacterium", "hallii", "Coprococcus", "Dialister", "Weissella")) %>%
  dplyr::filter(subID=="G14") # outlier on Cronobacter abundance
## # A tibble: 1 × 5
##   name        subID value is.outlier is.extreme
##   <chr>       <chr> <dbl> <lgl>      <lgl>     
## 1 Cronobacter G14   -5.37 TRUE       FALSE

Winsorize low microbiome outlier

To demonstrate code, we will winsorize G40 (low outlier) on Cronobacter abundance

# initialize a new dataset
mb_data_brainint_win <- mb_data_brainint %>% rownames_to_column(var = "subID")

# get the second highest coproccocus value to replace the outlier with (based on visual inspection, second highest value is ok)
bottom_2_Cronobacter_values <- mb_data_brainint %>% 
  arrange(Cronobacter) %>% 
  slice_head(n=2) %>% 
  dplyr::select(Cronobacter)

bottom_2_Cronobacter_values$Cronobacter[2]
## [1] -3.005527
# replace both outlier sub's Cronobacter value with the second highest
mb_data_brainint_win$Cronobacter[mb_data_brainint_win$subID=="G40"] <- bottom_2_Cronobacter_values$Cronobacter[2]

# convert subID column back to rowname for reading into spls
ids <- mb_data_brainint_win %>% dplyr::select(subID)
mb_data_brainint_win <- mb_data_brainint_win %>% dplyr::select(-subID) 
rownames(mb_data_brainint_win) <- ids$subID
## Warning: Setting row names on a tibble is deprecated.

Microbial Profiles(s) with SOFA, MTL, SAL Intra-Network Signature, low outlier winsorized

# initial sPLS model (should specify a large number of components first)
tune.spls1.braincomp.mbwin <- pls(X=mb_data_brainint_win, Y=metadata_comp$brain_int_win_comp1, ncomp=4, mode='regression')

# evaluate number of variables to select from X matrix (using number of components selected above)
list.keepX <- c(5:10, seq(15, 64, 5)) # specify selection up to the number of features in the dataset (64)

# evaluate tuning w/ R^2
set.seed(main.seed)
tune.spls1.braincomp.mbwin.R2 <- mixOmics::tune.spls(mb_data_brainint_win, metadata_comp$brain_int_win_comp1, ncomp= 2, 
                            test.keepX = list.keepX, 
                            validation = 'Mfold', 
                            folds = 10,
                            nrepeat = 100, 
                            progressBar = TRUE,
                            measure = 'R2') 
## 
## comp 1 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
## comp 2 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
plot(tune.spls1.braincomp.mb.R2) #highest R^2 (0.02) is with 2 component and 60 features each. Like before, we will set 1 component with 15 features to be consistent w the real dataset

#how many components to keep w this?
choice.ncomp <- 1 #set manually
# how many x variables with 1 component? 5
choice.keepX <- tune.spls1.braincomp.mbwin.R2$choice.keepX[1:1] #
choice.keepX <- 15

# specify final model with 1 components, 5 features on comp1
spls1.braincomp.mbwin <- spls(X=mb_data_brainint_win, Y=metadata_comp$brain_int_win_comp1, ncomp = choice.ncomp, keepX = choice.keepX, mode = "regression")

# extract list of features that were selected (each component is orthogonal)
#selectVar(spls1.braincomp.mbwin, comp = 1)$X$name 
plotLoadings(spls1.braincomp.mbwin, 'X') # positive is Eubacteriaceae; negative is Anaerobutyricum hallii, coproccocus, weissella, and dialister

selectVar(spls1.braincomp.mbwin, comp = 1)$X$value
##                        value.var
## Prevotella           0.624787429
## Dialister            0.460234407
## Faecalitalea         0.332007232
## Ruminiclostridium   -0.274728118
## Peptoclostridium    -0.269284889
## Ruminiclostridium.5  0.198447657
## Actinomyces          0.194025627
## Alistipes            0.182713713
## Terrisporobacter     0.131748517
## Intestinibacter     -0.092198341
## Bacteroides          0.035854808
## Hungatella           0.030946564
## Blautia              0.026559530
## Enterococcus         0.018234488
## NC2004              -0.007428442
plot(spls1.braincomp.mbwin$variates$X, spls1.braincomp.mbwin$variates$Y,
     xlab = 'X component', ylab = 'y component / scaled y') #

cor(spls1.braincomp.mbwin$variates$X, spls1.braincomp.mbwin$variates$Y) # cor = .65
##           comp1
## comp1 0.6128758
spls1.braincomp.mbwin$prop_expl_var$X #3%
##      comp1 
## 0.04148718
# create a table with genus, loading, and vip for each microbe
mb_pattern1_loadings <- selectVar(spls1.braincomp.mbwin, comp = 1)$X$value %>% rownames_to_column(var = "bacterium")
colnames(mb_pattern1_loadings) <- c("bacterium", "loading")

# determine the variable importance (loading magnitude weighted by variance explained?)
vip.spls1.braincomp1.mb <- vip(spls1.braincomp.mbwin)
braincomp1_vip <- as.data.frame(vip.spls1.braincomp1.mb[selectVar(spls1.braincomp.mbwin, comp=1)$X$name, 1]) %>% rownames_to_column(var= "bacterium") # 10 variables with VIP above 1 in comp 1
colnames(braincomp1_vip) <- c("bacterium", "VIP")

# merge loadings with vip
mb_pattern1_loadings_vip <- mb_pattern1_loadings %>% 
  left_join(braincomp1_vip, by = "bacterium") %>% 
  dplyr::mutate(loading = signif(loading, 2), VIP = signif(VIP, 2),
                braincomp = "SOFA, MTL, SAL Intra-Network",
                profile = "microbial profile 1")

# extract scores for mb component associated with brain comp1
braincomp1.mbwin <- as.data.frame(spls1.braincomp.mbwin$variates$X) %>% 
  dplyr::rename(mb_braincomp1 = comp1) %>% 
  rownames_to_column(var="subID")

Graph Microbe Loadings for SOFA, MTL, SAL Intra-Network Signature

There are 9 microbes with VIP > 1

# extract feature loadings
braincomp1_mb <- selectVar(spls1.braincomp.mbwin, comp = 1)$X$value %>% rownames_to_column(var = "genus")
colnames(braincomp1_mb)[2] <- "loading_C1"

# rename microbes whose name was cut off inappropriately when names were shortened: UCG.008, stricto,   
# __, coprostanoligenes
braincomp1_mb$genus[braincomp1_mb$genus == "UCG.008"] <- "Lachnospiraceae UCG-008" 
braincomp1_mb$genus[braincomp1_mb$genus == "stricto"] <- "Clostridium sensu stricto" 
braincomp1_mb$genus[braincomp1_mb$genus == "__"] <- "Mollicutes" 
braincomp1_mb$genus[braincomp1_mb$genus == "coprostanoligenes"] <- "Eubacterium" 
braincomp1_mb$genus[braincomp1_mb$genus == "AD3011"] <- "Clostridiales Family XIII" 

# create a factor that sorts the loadings by magnitude 
braincomp1_mb$genus <- factor(braincomp1_mb$genus, levels = braincomp1_mb$genus[order(braincomp1_mb$loading_C1, decreasing = TRUE)])

# graph the 9 highest loadings (those with VIP >1 )by magnitude
mb_pattern1 <- ggplot(braincomp1_mb %>% slice_max(., n=9, order_by=abs(loading_C1)), aes(x = reorder(genus, loading_C1), y = loading_C1)) +
  geom_col(fill = '#95cacb') + 
  coord_flip() +
  ylab("Loading") + xlab("Genus") +
  labs(tag = "B") +
  theme_bw() +
  theme(axis.text.x = element_text(color="black", size=12), axis.text.y = element_text(color="black", size=12), axis.title = element_text(size=16), plot.margin = margin(10, 10, 10, 10), plot.tag=element_text(size=14)) +
  ggtitle("Microbial \n Profile 1") +
  theme(plot.title = element_text(hjust=0.5, size=14, face='bold'))

Microbial Profile(s) with SOFA Inter-Network Signature

# initial sPLS model (should specify a large number of components first)
tune.spls1.braincomp2.mb <- pls(X=mb_data_brainint, Y=brain.int.win.comp_scores$brain_int_win_comp2, ncomp=4, mode='regression')

# evaluate number of variables to select from X matrix (using number of components selected above)
list.keepX <- c(5:10, seq(15, 64, 5)) # specify selection up to the number of features in the dataset (64)

# evaluate tuning w/ R^2 (keeping the maximum possible number of components at 2 to be consistent with real dataset)
set.seed(main.seed)
tune.spls1.braincomp2.mbwin.R2 <- mixOmics::tune.spls(mb_data_brainint_win, brain.int.win.comp_scores$brain_int_win_comp2, ncomp= 2, 
                            test.keepX = list.keepX, 
                            validation = 'Mfold', 
                            folds = 10,
                            nrepeat = 100, 
                            progressBar = TRUE,
                            measure = 'R2') 
## 
## comp 1 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
## comp 2 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |==                                                                    |   4%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |=======================                                               |  34%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
plot(tune.spls1.braincomp2.mbwin.R2) #highest R^2 (0.02) is with 1 component with 7 features; for the sake of staying consistent with the real dataset, we will set the number of components to 2

#how many components to keep w this?
choice.ncomp <- 2 #2
# how many x variables with 1 component? 5
choice.keepX <- tune.spls1.braincomp2.mbwin.R2$choice.keepX[1:2] #5 features

# specify final model with 2 components (best for model parsimony)
spls1.braincomp2.mb <- spls(X=mb_data_brainint, Y=brain.int.win.comp_scores$brain_int_win_comp2, ncomp = choice.ncomp, keepX = choice.keepX, mode = "regression")

# evaluate the overall model
plot(spls1.braincomp2.mb$variates$X, spls1.braincomp2.mb$variates$Y,
     xlab = 'X component', ylab = 'y component / scaled y') #looks like a nicer scatterplot than for comp1

cor(spls1.braincomp2.mb$variates$X, spls1.braincomp2.mb$variates$Y) # cor = .46, 0.52
##           comp1        comp2
## comp1 0.5990675 1.741093e-16
## comp2 0.3463088 4.325084e-01
spls1.braincomp2.mb$prop_expl_var$X #3%
##      comp1      comp2 
## 0.03592348 0.04097430
# create a table with genus, loading, and vip for each microbe
mb_pattern2_loadings <- selectVar(spls1.braincomp2.mb, comp = 1)$X$value %>% rownames_to_column(var = "bacterium")
colnames(mb_pattern2_loadings) <- c("bacterium", "loading")

mb_pattern3_loadings <- selectVar(spls1.braincomp2.mb, comp = 2)$X$value %>% rownames_to_column(var = "bacterium")
colnames(mb_pattern3_loadings) <- c("bacterium", "loading")

# determine the variable importance (loading magnitude weighted by variance explained?)
vip.spls1.braincomp1.mb <- vip(spls1.braincomp2.mb)
mb_pattern2_vip <- as.data.frame(vip.spls1.braincomp1.mb[selectVar(spls1.braincomp2.mb, comp=1)$X$name, 1]) %>% rownames_to_column(var= "bacterium") # 10 variables with VIP above 1 in comp 1
colnames(mb_pattern2_vip) <- c("bacterium", "VIP")

mb_pattern3_vip <- as.data.frame(vip.spls1.braincomp1.mb[selectVar(spls1.braincomp2.mb, comp=2)$X$name, 2]) %>% rownames_to_column(var= "bacterium") # 10 variables with VIP above 1 in comp 1
colnames(mb_pattern3_vip) <- c("bacterium", "VIP")

# merge loadings with vip
mb_pattern2_loadings_vip <- mb_pattern2_loadings %>% 
  left_join(mb_pattern2_vip, by = "bacterium") %>% 
  dplyr::mutate(loading = signif(loading, 2), VIP = signif(VIP, 2),
                braincomp = "SOFA Inter-Network",
                profile = "microbial profile 2")

mb_pattern3_loadings_vip <- mb_pattern3_loadings %>% 
  left_join(mb_pattern3_vip, by = "bacterium") %>% 
  dplyr::mutate(loading = signif(loading, 2), VIP = signif(VIP, 2),
                braincomp = "SOFA Inter-Network",
                profile = "microbial profile 3")

# merge loadings, vips for all 3 microbial profiles, write the output
mb_loadings_vip <- rbind(mb_pattern1_loadings_vip, mb_pattern2_loadings_vip, mb_pattern3_loadings_vip)
write_csv(mb_pattern3_loadings, "tables_demo/TableS3.csv")

# extract scores for mb component associated with brain comp2
braincomp2.mbwin <- as.data.frame(spls1.braincomp2.mb$variates$X) %>% 
  dplyr::rename(mb1_braincomp2 = comp1,
                mb2_braincomp2 = comp2) %>% 
  rownames_to_column(var="subID")

Graph Microbe Loadings for SOFA Inter-Network Signature, and Visualize all Microbial Profiles Together

profile 2: 5 microbes with vip > 1, profile 3: 4 microbes with vip>1

# extract feature loadings
braincomp2_mb1 <- selectVar(spls1.braincomp2.mb, comp = 1)$X$value %>% rownames_to_column(var = "genus")
colnames(braincomp2_mb1)[2] <- "loading_C1"
braincomp2_mb2 <- selectVar(spls1.braincomp2.mb, comp = 2)$X$value %>% rownames_to_column(var = "genus")
colnames(braincomp2_mb2)[2] <- "loading_C2"

# rename microbes whose names got messed up when classifications were shortened in pre-processing: gauvreauii, UCG.008
braincomp2_mb1$genus[braincomp2_mb1$genus == "gauvreauii"] <- "Ruminococcus"
braincomp2_mb2$genus[braincomp2_mb2$genus == "UCG.008"] <- "Lachnospiraceae UCG-008"

# create a factor that sorts the loadings by magnitude 
braincomp2_mb1$genus <- factor(braincomp2_mb1$genus, levels = braincomp2_mb1$genus[order(braincomp2_mb1$loading_C1, decreasing = TRUE)])

braincomp2_mb2$genus <- factor(braincomp2_mb2$genus, levels = braincomp2_mb2$genus[order(braincomp2_mb2$loading_C2, decreasing = TRUE)])

# graph loadings for second microbial profile by magnitude (4 loadings have VIP > 1)
mb_pattern2 <- ggplot(braincomp2_mb1 %>% slice_max(., n=6, order_by=abs(loading_C1)), aes(x = reorder(genus, loading_C1), y = loading_C1)) +
  geom_col(fill = '#fd988d') + 
  coord_flip() +
  ylab("Loading") + xlab("Genus") +
  labs(tag = "D") + 
  theme_bw() +
  theme(axis.text.x = element_text(color="black", size=12), axis.text.y = element_text(color="black", size=12), axis.title = element_text(size=16), plot.margin = margin(10, 10, 10, 10), plot.tag=element_text(size=14)) + 
  ggtitle("Microbial \n Profile 2") +
  theme(plot.title = element_text(hjust=0.5, size=14, face='bold'))

#ggsave('../../../../Users/Fran/conferences/bridget_australia/mbcomp1_brain2.jpg', width = 9, height=7, dpi=1000)

# graph 10 highest loadings by magnitude for third microbial profile (3 vars have VIP > 1)
mb_pattern3 <- 
  ggplot(braincomp2_mb2 %>% slice_max(., n=4, order_by=abs(loading_C2)), aes(x = reorder(genus, loading_C2), y = loading_C2)) +
  geom_col(fill = '#fd988d') + 
  coord_flip() +
  ylab("Loading") + xlab("Genus") +
  labs(tag = "E") + 
  theme_bw() +
  theme(axis.text.x = element_text(color="black", size=12), axis.text.y = element_text(color="black", size=12), axis.title = element_text(size=16), plot.margin = margin(10, 10, 10, 10), plot.tag=element_text(size=14)) +
  ggtitle("Microbial \n Profile 3") +
  theme(plot.title = element_text(hjust=0.5, size=14, face='bold'))

# save all 3 of the microbiome patterns together
library(patchwork)
mb_pattern1 + mb_pattern2 + mb_pattern3

ggsave('figures_demo/Figure2.png', mb_pattern1 + mb_pattern2 + mb_pattern3, width = 12, height=5, dpi=1000)

STOPPED HERE

Microbial Profiles –> Brain Signatures Regression Models

Association of Microbial Profiles with Brain Signatures, controlling for covariates

Covariates are PUFA, dietary fat, fiber, GA, BW, and sex

# add mb component scores to larger dataset with all covs and brain comp scores
all_data <- metadata_comp %>% dplyr::left_join(braincomp1.mbwin, by = "subID") %>% left_join(braincomp2.mbwin, by = "subID") 

# comp1 mb, comp1 brain
braincomp1_mb <- lm(brain_int_win_comp1 ~ mb_braincomp1 + sex_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + `PUFA_%` + meanFD_centered, data = all_data)
tab_model(braincomp1_mb, robust=TRUE, show.std=TRUE, show.se=TRUE) #
  brain int win comp 1
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 0.28 0.93 -0.00 0.13 -1.59 – 2.14 -0.25 – 0.25 0.766
mb braincomp1 0.54 0.11 0.62 0.13 0.31 – 0.77 0.36 – 0.88 <0.001
sex centered 0.07 0.18 0.06 0.16 -0.30 – 0.44 -0.26 – 0.38 0.708
BW centered 0.02 0.41 0.01 0.13 -0.80 – 0.84 -0.26 – 0.27 0.959
deliv mode -0.24 0.32 -0.10 0.14 -0.88 – 0.40 -0.38 – 0.17 0.456
Fat %energy -0.01 0.03 -0.07 0.16 -0.06 – 0.04 -0.40 – 0.25 0.661
Fibre per 1000kcal -0.02 0.05 -0.04 0.14 -0.12 – 0.09 -0.32 – 0.23 0.750
PUFA % 0.01 0.01 0.10 0.12 -0.01 – 0.02 -0.14 – 0.33 0.411
meanFD centered 1.71 6.08 0.04 0.16 -10.52 – 13.95 -0.27 – 0.36 0.780
Observations 55
R2 / R2 adjusted 0.412 / 0.310
braincomp1_mb_ncovs <- lm(brain_int_win_comp1 ~ mb_braincomp1, data = all_data)
tab_model(braincomp1_mb_ncovs, robust=TRUE, show.std=TRUE, show.se=TRUE) #
  brain int win comp 1
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 0.00 0.12 -0.00 0.11 -0.24 – 0.24 -0.22 – 0.22 1.000
mb braincomp1 0.53 0.08 0.61 0.10 0.36 – 0.70 0.42 – 0.81 <0.001
Observations 55
R2 / R2 adjusted 0.376 / 0.364
# comp1 mb, comp2 brain
braincomp2_mb1 <- lm(brain_int_win_comp2 ~ mb1_braincomp2 + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + `PUFA_%` + meanFD_centered, data = all_data)
tab_model(braincomp2_mb1, robust=TRUE, show.std=TRUE, show.se=TRUE) #
  brain int win comp 2
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) -0.34 0.89 0.00 0.12 -2.12 – 1.45 -0.25 – 0.25 0.707
mb1 braincomp2 0.62 0.14 0.64 0.15 0.33 – 0.91 0.34 – 0.94 <0.001
sex centered -0.14 0.16 -0.12 0.14 -0.46 – 0.19 -0.39 – 0.16 0.400
GA centered -0.15 0.11 -0.14 0.10 -0.37 – 0.06 -0.33 – 0.06 0.157
BW centered 0.22 0.36 0.07 0.11 -0.51 – 0.95 -0.16 – 0.30 0.550
deliv mode 0.14 0.39 0.06 0.16 -0.64 – 0.91 -0.26 – 0.37 0.728
Fat %energy -0.00 0.02 -0.01 0.12 -0.04 – 0.04 -0.24 – 0.23 0.964
Fibre per 1000kcal 0.07 0.05 0.19 0.13 -0.03 – 0.17 -0.07 – 0.45 0.154
PUFA % -0.00 0.01 -0.02 0.12 -0.02 – 0.02 -0.27 – 0.24 0.901
meanFD centered 1.04 5.09 0.03 0.13 -9.20 – 11.29 -0.23 – 0.28 0.838
Observations 55
R2 / R2 adjusted 0.417 / 0.301
braincomp2_mb_ncovs <- lm(brain_int_win_comp2 ~ mb1_braincomp2, data = all_data)
tab_model(braincomp2_mb_ncovs, robust=TRUE, show.std=TRUE) #
  brain int win comp 2
Predictors Estimates std. Beta CI standardized CI p
(Intercept) -0.00 0.00 -0.26 – 0.26 -0.22 – 0.22 1.000
mb1 braincomp2 0.58 0.60 0.36 – 0.79 0.38 – 0.82 <0.001
Observations 55
R2 / R2 adjusted 0.359 / 0.347
# comp2 mb, comp2 brain
braincomp2_mb2 <- lm(brain_int_win_comp2 ~ mb2_braincomp2 + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + `PUFA_%` + GA_centered, data = all_data)
tab_model(braincomp2_mb2, robust=TRUE, show.std=TRUE, show.se=TRUE) #positive, B=.59, p = .012
  brain int win comp 2
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) -1.04 0.87 0.00 0.14 -2.79 – 0.72 -0.29 – 0.29 0.240
mb2 braincomp2 0.41 0.17 0.37 0.16 0.06 – 0.76 0.05 – 0.69 0.024
sex centered 0.04 0.22 0.03 0.19 -0.41 – 0.48 -0.34 – 0.40 0.866
GA centered 0.11 0.19 0.10 0.17 -0.27 – 0.49 -0.25 – 0.44 0.572
BW centered -0.02 0.40 -0.01 0.13 -0.83 – 0.79 -0.26 – 0.25 0.961
deliv mode 0.35 0.45 0.14 0.18 -0.55 – 1.24 -0.23 – 0.51 0.442
Fat %energy 0.01 0.02 0.04 0.12 -0.03 – 0.05 -0.20 – 0.29 0.729
Fibre per 1000kcal 0.06 0.07 0.16 0.17 -0.07 – 0.19 -0.19 – 0.50 0.359
PUFA % 0.01 0.01 0.11 0.16 -0.02 – 0.03 -0.21 – 0.43 0.493
Observations 55
R2 / R2 adjusted 0.186 / 0.044
braincomp2_mb_ncovs <- lm(brain_int_win_comp2 ~ mb2_braincomp2, data = all_data)
tab_model(braincomp2_mb_ncovs, robust=TRUE, show.std=TRUE) #positive, B=0.55, p < .001
  brain int win comp 2
Predictors Estimates std. Beta CI standardized CI p
(Intercept) -0.00 -0.00 -0.30 – 0.30 -0.26 – 0.26 1.000
mb2 braincomp2 0.38 0.35 0.10 – 0.66 0.10 – 0.60 0.008
Observations 55
R2 / R2 adjusted 0.120 / 0.103

Mediation Analysis

Association of Microbial Profiles with Internalizing Symptoms, controlling for covariates (Mediation Model Total Effects)

# microbial profile 1
braincomp1_comp1mb_int <- lm(cbclintprobtot_y7_pos_boxcox ~ mb_braincomp1 + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + `PUFA_%` + meanFD_centered, data = all_data)
tab_model(braincomp1_comp1mb_int, robust=TRUE, show.std=TRUE, show.se=TRUE) #ns, B = .28, p = .14 (in real dataset)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 1.76 1.03 0.00 0.14 -0.31 – 3.83 -0.28 – 0.28 0.093
mb braincomp1 0.39 0.13 0.40 0.14 0.12 – 0.65 0.13 – 0.68 0.005
sex centered 0.17 0.19 0.13 0.15 -0.22 – 0.55 -0.17 – 0.43 0.384
GA centered 0.03 0.17 0.02 0.15 -0.32 – 0.38 -0.28 – 0.32 0.877
BW centered 0.03 0.50 0.01 0.15 -0.97 – 1.03 -0.29 – 0.30 0.950
deliv mode -0.42 0.43 -0.16 0.16 -1.27 – 0.44 -0.49 – 0.17 0.334
Fat %energy -0.01 0.02 -0.05 0.11 -0.05 – 0.03 -0.28 – 0.18 0.636
Fibre per 1000kcal -0.00 0.07 -0.01 0.16 -0.14 – 0.13 -0.34 – 0.32 0.967
PUFA % 0.02 0.01 0.24 0.14 -0.00 – 0.04 -0.04 – 0.52 0.086
meanFD centered -4.39 6.64 -0.10 0.16 -17.76 – 8.98 -0.42 – 0.21 0.512
Observations 55
R2 / R2 adjusted 0.255 / 0.106
braincomp1_comp1mb_int_ncovs <- lm(cbclintprobtot_y7_pos_boxcox ~ mb_braincomp1, data = all_data)
tab_model(braincomp1_comp1mb_int_ncovs, robust=TRUE, show.std=TRUE, show.se=TRUE) # significant, B = .32, p = .01 (in real dataset)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 2.07 0.16 0.00 0.13 1.76 – 2.39 -0.26 – 0.26 <0.001
mb braincomp1 0.36 0.11 0.38 0.11 0.14 – 0.58 0.15 – 0.61 0.002
Observations 55
R2 / R2 adjusted 0.144 / 0.128
# microbial profile 2
braincomp2_comp1mb_int <- lm(cbclintprobtot_y7_pos_boxcox ~ mb1_braincomp2 + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + `PUFA_%` + meanFD_centered, data = all_data)
tab_model(braincomp2_comp1mb_int, robust=TRUE, show.std=TRUE, show.se=TRUE) # ns, B = .37, p = .06
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 1.86 0.99 0.00 0.14 -0.14 – 3.86 -0.29 – 0.29 0.068
mb1 braincomp2 0.38 0.16 0.38 0.15 0.07 – 0.70 0.07 – 0.68 0.017
sex centered 0.12 0.18 0.09 0.15 -0.25 – 0.49 -0.20 – 0.39 0.520
GA centered -0.04 0.17 -0.03 0.15 -0.38 – 0.31 -0.33 – 0.26 0.829
BW centered -0.06 0.54 -0.02 0.16 -1.15 – 1.03 -0.34 – 0.31 0.913
deliv mode -0.51 0.40 -0.20 0.15 -1.31 – 0.29 -0.51 – 0.11 0.207
Fat %energy -0.00 0.02 -0.02 0.12 -0.05 – 0.04 -0.27 – 0.23 0.888
Fibre per 1000kcal -0.01 0.07 -0.02 0.16 -0.14 – 0.12 -0.35 – 0.31 0.897
PUFA % 0.01 0.01 0.18 0.14 -0.01 – 0.04 -0.09 – 0.45 0.195
meanFD centered -2.18 6.80 -0.05 0.16 -15.88 – 11.52 -0.37 – 0.27 0.750
Observations 55
R2 / R2 adjusted 0.223 / 0.068
braincomp2_comp1mb_int_ncovs <- lm(cbclintprobtot_y7_pos_boxcox ~ mb1_braincomp2, data = all_data)
tab_model(braincomp2_comp1mb_int_ncovs, robust=TRUE, show.std=TRUE) # ns, B = .22, p = .17 (in real dataset)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Beta CI standardized CI p
(Intercept) 2.07 0.00 1.76 – 2.39 -0.26 – 0.26 <0.001
mb1 braincomp2 0.37 0.37 0.12 – 0.63 0.11 – 0.62 0.005
Observations 55
R2 / R2 adjusted 0.134 / 0.117
# microbial profile 3
braincomp2_comp2mb_int <- lm(cbclintprobtot_y7_pos_boxcox ~ mb2_braincomp2 + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + `PUFA_%` + meanFD_centered, data = all_data)
tab_model(braincomp2_comp2mb_int, robust=TRUE, show.std=TRUE, show.se=TRUE) # ns, B = .07, p = .78 (in real dataset)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 1.47 1.01 0.00 0.15 -0.56 – 3.50 -0.31 – 0.31 0.152
mb2 braincomp2 -0.07 0.22 -0.06 0.19 -0.51 – 0.37 -0.44 – 0.32 0.762
sex centered 0.20 0.21 0.16 0.17 -0.23 – 0.63 -0.18 – 0.50 0.358
GA centered 0.05 0.20 0.04 0.17 -0.36 – 0.46 -0.31 – 0.39 0.805
BW centered -0.06 0.57 -0.02 0.17 -1.21 – 1.08 -0.36 – 0.32 0.910
deliv mode -0.32 0.45 -0.12 0.17 -1.23 – 0.59 -0.47 – 0.23 0.485
Fat %energy 0.00 0.02 0.01 0.12 -0.04 – 0.05 -0.23 – 0.26 0.924
Fibre per 1000kcal -0.00 0.08 -0.01 0.19 -0.15 – 0.15 -0.38 – 0.37 0.965
PUFA % 0.02 0.01 0.21 0.14 -0.01 – 0.04 -0.08 – 0.50 0.152
meanFD centered -1.35 6.87 -0.03 0.16 -15.20 – 12.50 -0.36 – 0.29 0.845
Observations 55
R2 / R2 adjusted 0.105 / -0.074
braincomp2_comp2mb_int_ncovs <- lm(cbclintprobtot_y7_pos_boxcox ~ mb2_braincomp2, data = all_data)
tab_model(braincomp2_comp2mb_int_ncovs, robust=TRUE, show.std=TRUE) # ns, B = .21, p = .14 (in real dataset)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Beta CI standardized CI p
(Intercept) 2.07 0.00 1.73 – 2.41 -0.28 – 0.28 <0.001
mb2 braincomp2 -0.14 -0.12 -0.49 – 0.20 -0.42 – 0.17 0.408
Observations 55
R2 / R2 adjusted 0.015 / -0.004
# faith
faith_internalizing <- lm(cbclintprobtot_y7_pos_boxcox ~ faith_pd + sex_centered + GA_centered + BW_centered + deliv_mode + `Fat_%energy` + Fibre.per.1000kcal + `PUFA_%` + meanFD_centered, data = all_data)
tab_model(faith_internalizing, robust=TRUE, show.std=TRUE, show.se=TRUE)
  cbclintprobtot y 7 pos
boxcox
Predictors Estimates std. Error std. Beta standardized std. Error CI standardized CI p
(Intercept) 2.01 1.08 0.00 0.15 -0.16 – 4.18 -0.30 – 0.30 0.068
faith pd -0.25 0.15 -0.35 0.21 -0.54 – 0.05 -0.77 – 0.06 0.096
sex centered 0.10 0.22 0.08 0.17 -0.34 – 0.53 -0.27 – 0.42 0.657
GA centered 0.16 0.19 0.13 0.16 -0.23 – 0.54 -0.19 – 0.46 0.416
BW centered -0.35 0.55 -0.10 0.16 -1.45 – 0.75 -0.43 – 0.22 0.528
deliv mode -0.60 0.46 -0.23 0.18 -1.53 – 0.34 -0.59 – 0.13 0.206
Fat %energy 0.02 0.02 0.09 0.12 -0.03 – 0.06 -0.14 – 0.32 0.451
Fibre per 1000kcal 0.06 0.09 0.16 0.21 -0.11 – 0.24 -0.27 – 0.58 0.466
PUFA % 0.02 0.01 0.23 0.14 -0.00 – 0.04 -0.05 – 0.51 0.105
meanFD centered -2.43 5.95 -0.06 0.14 -14.42 – 9.57 -0.34 – 0.23 0.686
Observations 55
R2 / R2 adjusted 0.178 / 0.013

Mediation Models: Microbiome Features –> Brain Signatures –> Internalizing Symptoms

Before using process run entire process.R script from Andrew Hayes to load the process() function

# rename columns in all data with % in them to get function to work
all_data <- all_data %>% dplyr::mutate(
  Fat_perc_energy = `Fat_%energy`,
  PUFA_perc = `PUFA_%`
)

# **transformed var, process**
process(data=all_data, y="cbclintprobtot_y7_pos_boxcox", x="mb_braincomp1", m=c("brain_int_win_comp1"), cov=c("sex_centered", "GA_centered", "BW_centered", "deliv_mode", "Fat_%energy", "Fibre.per.1000kcal", "PUFA_%", "meanFD_centered"), model=4, seed=100770, stand=1) # 
## 
## ********************* PROCESS for R Version 4.3.1 ********************* 
##  
##            Written by Andrew F. Hayes, Ph.D.  www.afhayes.com              
##    Documentation available in Hayes (2022). www.guilford.com/p/hayes3   
##  
## *********************************************************************** 
##                                     
## Model : 4                           
##     Y : cbclintprobtot_y7_pos_boxcox
##     X : mb_braincomp1               
##     M : brain_int_win_comp1         
## 
## Covariates: 
##        sex_centered GA_centered BW_centered deliv_mode Fat_%energy Fibre.per.1000kcal PUFA_% meanFD_centered
## 
## Sample size: 55
## 
## Custom seed: 100770
## 
## 
## *********************************************************************** 
## Outcome Variable: brain_int_win_comp1
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.6561    0.4305    0.8473    3.7801    9.0000   45.0000    0.0013
## 
## Model: 
##                        coeff        se         t         p      LLCI      ULCI
## constant              0.2174    0.7327    0.2967    0.7680   -1.2583    1.6931
## mb_braincomp1         0.5293    0.1011    5.2353    0.0000    0.3257    0.7329
## sex_centered          0.0701    0.1430    0.4901    0.6265   -0.2179    0.3581
## GA_centered           0.1467    0.1226    1.1963    0.2379   -0.1003    0.3936
## BW_centered          -0.0286    0.3673   -0.0779    0.9383   -0.7684    0.7112
## deliv_mode           -0.2913    0.2781   -1.0476    0.3004   -0.8515    0.2688
## Fat_%energy          -0.0104    0.0193   -0.5383    0.5930   -0.0492    0.0285
## Fibre.per.1000kcal   -0.0165    0.0437   -0.3774    0.7077   -0.1046    0.0716
## PUFA_%                0.0072    0.0087    0.8289    0.4116   -0.0103    0.0247
## meanFD_centered       1.6826    4.6205    0.3642    0.7174   -7.6237   10.9889
## 
## Standardized coefficients:
##                        coeff
## mb_braincomp1         0.6099
## sex_centered          0.0611
## GA_centered           0.1377
## BW_centered          -0.0093
## deliv_mode           -0.1239
## Fat_%energy          -0.0638
## Fibre.per.1000kcal   -0.0449
## PUFA_%                0.0957
## meanFD_centered       0.0437
## 
## *********************************************************************** 
## Outcome Variable: cbclintprobtot_y7_pos_boxcox
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.5778    0.3338    1.2293    2.2048   10.0000   44.0000    0.0354
## 
## Model: 
##                         coeff        se         t         p      LLCI      ULCI
## constant               1.6729    0.8834    1.8938    0.0648   -0.1074    3.4532
## mb_braincomp1          0.1700    0.1545    1.1007    0.2770   -0.1413    0.4814
## brain_int_win_comp1    0.4096    0.1796    2.2815    0.0274    0.0478    0.7715
## sex_centered           0.1379    0.1727    0.7984    0.4289   -0.2102    0.4860
## GA_centered           -0.0330    0.1500   -0.2198    0.8270   -0.3353    0.2693
## BW_centered            0.0427    0.4424    0.0966    0.9235   -0.8490    0.9344
## deliv_mode            -0.2959    0.3390   -0.8729    0.3875   -0.9792    0.3873
## Fat_%energy           -0.0055    0.0233   -0.2370    0.8137   -0.0525    0.0414
## Fibre.per.1000kcal     0.0040    0.0527    0.0766    0.9393   -0.1023    0.1103
## PUFA_%                 0.0172    0.0105    1.6300    0.1102   -0.0041    0.0384
## meanFD_centered       -5.0818    5.5736   -0.9118    0.3669  -16.3147    6.1511
## 
## Standardized coefficients:
##                         coeff
## mb_braincomp1          0.1779
## brain_int_win_comp1    0.3720
## sex_centered           0.1092
## GA_centered           -0.0281
## BW_centered            0.0126
## deliv_mode            -0.1143
## Fat_%energy           -0.0306
## Fibre.per.1000kcal     0.0099
## PUFA_%                 0.2077
## meanFD_centered       -0.1197
## 
## *********************************************************************** 
## Bootstrapping progress:
## 
  |                                                                    
  |                                                              |   0%
  |                                                                    
  |                                                              |   1%
  |                                                                    
  |>                                                             |   1%
  |                                                                    
  |>                                                             |   2%
  |                                                                    
  |>>                                                            |   2%
  |                                                                    
  |>>                                                            |   3%
  |                                                                    
  |>>                                                            |   4%
  |                                                                    
  |>>>                                                           |   4%
  |                                                                    
  |>>>                                                           |   5%
  |                                                                    
  |>>>                                                           |   6%
  |                                                                    
  |>>>>                                                          |   6%
  |                                                                    
  |>>>>                                                          |   7%
  |                                                                    
  |>>>>>                                                         |   7%
  |                                                                    
  |>>>>>                                                         |   8%
  |                                                                    
  |>>>>>                                                         |   9%
  |                                                                    
  |>>>>>>                                                        |   9%
  |                                                                    
  |>>>>>>                                                        |  10%
  |                                                                    
  |>>>>>>>                                                       |  10%
  |                                                                    
  |>>>>>>>                                                       |  11%
  |                                                                    
  |>>>>>>>                                                       |  12%
  |                                                                    
  |>>>>>>>>                                                      |  12%
  |                                                                    
  |>>>>>>>>                                                      |  13%
  |                                                                    
  |>>>>>>>>                                                      |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  16%
  |                                                                    
  |>>>>>>>>>>                                                    |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  18%
  |                                                                    
  |>>>>>>>>>>>                                                   |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  21%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  24%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  26%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  29%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  32%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  34%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  37%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  39%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  42%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  45%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  47%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  50%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  53%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  55%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  58%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  61%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  63%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  66%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  68%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  71%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  74%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  76%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  79%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  82%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  84%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  87%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  89%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  92%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  95%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  97%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
## 
## **************** DIRECT AND INDIRECT EFFECTS OF X ON Y ****************
## 
## Direct effect of X on Y:
##      effect        se         t         p      LLCI      ULCI     c'_cs
##      0.1700    0.1545    1.1007    0.2770   -0.1413    0.4814    0.1779
## 
## Indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp1    0.2168    0.1101   -0.0058    0.4334
## 
## Completely standardized indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp1    0.2269    0.1107   -0.0069    0.4380
## 
## ******************** ANALYSIS NOTES AND ERRORS ************************ 
## 
## Level of confidence for all confidence intervals in output: 95
## 
## Number of bootstraps for percentile bootstrap confidence intervals: 5000
process(data=all_data, y="cbclintprobtot_y7_pos_boxcox", x="mb1_braincomp2", m=c("brain_int_win_comp2"), cov=c("sex_centered", "GA_centered", "BW_centered", "deliv_mode", "Fat_%energy", "Fibre.per.1000kcal", "PUFA_%", "meanFD_centered"), model=4, seed=100770, stand=1) # 
## 
## ********************* PROCESS for R Version 4.3.1 ********************* 
##  
##            Written by Andrew F. Hayes, Ph.D.  www.afhayes.com              
##    Documentation available in Hayes (2022). www.guilford.com/p/hayes3   
##  
## *********************************************************************** 
##                                     
## Model : 4                           
##     Y : cbclintprobtot_y7_pos_boxcox
##     X : mb1_braincomp2              
##     M : brain_int_win_comp2         
## 
## Covariates: 
##        sex_centered GA_centered BW_centered deliv_mode Fat_%energy Fibre.per.1000kcal PUFA_% meanFD_centered
## 
## Sample size: 55
## 
## Custom seed: 100770
## 
## 
## *********************************************************************** 
## Outcome Variable: brain_int_win_comp2
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.6461    0.4175    0.9306    3.5833    9.0000   45.0000    0.0020
## 
## Model: 
##                        coeff        se         t         p      LLCI      ULCI
## constant             -0.3351    0.7730   -0.4335    0.6667   -1.8921    1.2218
## mb1_braincomp2        0.6174    0.1182    5.2231    0.0000    0.3793    0.8555
## sex_centered         -0.1376    0.1518   -0.9064    0.3696   -0.4433    0.1681
## GA_centered          -0.1539    0.1319   -1.1666    0.2495   -0.4197    0.1118
## BW_centered           0.2187    0.3836    0.5701    0.5714   -0.5539    0.9912
## deliv_mode            0.1352    0.2957    0.4573    0.6496   -0.4604    0.7309
## Fat_%energy          -0.0009    0.0200   -0.0448    0.9645   -0.0412    0.0394
## Fibre.per.1000kcal    0.0713    0.0458    1.5553    0.1269   -0.0210    0.1635
## PUFA_%               -0.0012    0.0091   -0.1328    0.8950   -0.0196    0.0172
## meanFD_centered       1.0434    4.7902    0.2178    0.8286   -8.6046   10.6914
## 
## Standardized coefficients:
##                        coeff
## mb1_braincomp2        0.6419
## sex_centered         -0.1158
## GA_centered          -0.1394
## BW_centered           0.0687
## deliv_mode            0.0555
## Fat_%energy          -0.0053
## Fibre.per.1000kcal    0.1872
## PUFA_%               -0.0154
## meanFD_centered       0.0261
## 
## *********************************************************************** 
## Outcome Variable: cbclintprobtot_y7_pos_boxcox
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.5843    0.3414    1.2154    2.2804   10.0000   44.0000    0.0297
## 
## Model: 
##                         coeff        se         t         p      LLCI      ULCI
## constant               2.0164    0.8852    2.2778    0.0276    0.2323    3.8005
## mb1_braincomp2         0.0888    0.1712    0.5186    0.6067   -0.2563    0.4338
## brain_int_win_comp2    0.4785    0.1704    2.8086    0.0074    0.1351    0.8218
## sex_centered           0.1854    0.1750    1.0595    0.2952   -0.1673    0.5382
## GA_centered            0.0365    0.1530    0.2382    0.8128   -0.2720    0.3449
## BW_centered           -0.1641    0.4399   -0.3731    0.7109   -1.0507    0.7225
## deliv_mode            -0.5746    0.3387   -1.6963    0.0969   -1.2573    0.1081
## Fat_%energy           -0.0027    0.0229   -0.1197    0.9053   -0.0488    0.0434
## Fibre.per.1000kcal    -0.0427    0.0537   -0.7943    0.4313   -0.1510    0.0656
## PUFA_%                 0.0154    0.0104    1.4735    0.1477   -0.0057    0.0364
## meanFD_centered       -2.6823    5.4771   -0.4897    0.6268  -13.7207    8.3562
## 
## Standardized coefficients:
##                         coeff
## mb1_braincomp2         0.0869
## brain_int_win_comp2    0.4503
## sex_centered           0.1468
## GA_centered            0.0311
## BW_centered           -0.0485
## deliv_mode            -0.2219
## Fat_%energy           -0.0150
## Fibre.per.1000kcal    -0.1055
## PUFA_%                 0.1859
## meanFD_centered       -0.0632
## 
## *********************************************************************** 
## Bootstrapping progress:
## 
  |                                                                    
  |                                                              |   0%
  |                                                                    
  |                                                              |   1%
  |                                                                    
  |>                                                             |   1%
  |                                                                    
  |>                                                             |   2%
  |                                                                    
  |>>                                                            |   2%
  |                                                                    
  |>>                                                            |   3%
  |                                                                    
  |>>                                                            |   4%
  |                                                                    
  |>>>                                                           |   4%
  |                                                                    
  |>>>                                                           |   5%
  |                                                                    
  |>>>                                                           |   6%
  |                                                                    
  |>>>>                                                          |   6%
  |                                                                    
  |>>>>                                                          |   7%
  |                                                                    
  |>>>>>                                                         |   7%
  |                                                                    
  |>>>>>                                                         |   8%
  |                                                                    
  |>>>>>                                                         |   9%
  |                                                                    
  |>>>>>>                                                        |   9%
  |                                                                    
  |>>>>>>                                                        |  10%
  |                                                                    
  |>>>>>>>                                                       |  10%
  |                                                                    
  |>>>>>>>                                                       |  11%
  |                                                                    
  |>>>>>>>                                                       |  12%
  |                                                                    
  |>>>>>>>>                                                      |  12%
  |                                                                    
  |>>>>>>>>                                                      |  13%
  |                                                                    
  |>>>>>>>>                                                      |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  16%
  |                                                                    
  |>>>>>>>>>>                                                    |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  18%
  |                                                                    
  |>>>>>>>>>>>                                                   |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  21%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  24%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  26%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  29%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  32%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  34%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  37%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  39%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  42%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  45%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  47%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  50%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  53%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  55%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  58%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  61%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  63%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  66%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  68%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  71%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  74%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  76%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  79%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  82%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  84%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  87%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  89%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  92%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  95%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  97%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
## 
## **************** DIRECT AND INDIRECT EFFECTS OF X ON Y ****************
## 
## Direct effect of X on Y:
##      effect        se         t         p      LLCI      ULCI     c'_cs
##      0.0888    0.1712    0.5186    0.6067   -0.2563    0.4338    0.0868
## 
## Indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp2    0.2954    0.1220    0.0665    0.5457
## 
## Completely standardized indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp2    0.2890    0.1217    0.0617    0.5349
## 
## ******************** ANALYSIS NOTES AND ERRORS ************************ 
## 
## Level of confidence for all confidence intervals in output: 95
## 
## Number of bootstraps for percentile bootstrap confidence intervals: 5000
process(data=all_data, y="cbclintprobtot_y7_pos_boxcox", x="mb2_braincomp2", m=c("brain_int_win_comp2"), cov=c("sex_centered", "GA_centered", "BW_centered", "deliv_mode", "Fat_%energy", "Fibre.per.1000kcal", "PUFA_%", "meanFD_centered"), model=4, seed=100770, stand=1) # 
## 
## ********************* PROCESS for R Version 4.3.1 ********************* 
##  
##            Written by Andrew F. Hayes, Ph.D.  www.afhayes.com              
##    Documentation available in Hayes (2022). www.guilford.com/p/hayes3   
##  
## *********************************************************************** 
##                                     
## Model : 4                           
##     Y : cbclintprobtot_y7_pos_boxcox
##     X : mb2_braincomp2              
##     M : brain_int_win_comp2         
## 
## Covariates: 
##        sex_centered GA_centered BW_centered deliv_mode Fat_%energy Fibre.per.1000kcal PUFA_% meanFD_centered
## 
## Sample size: 55
## 
## Custom seed: 100770
## 
## 
## *********************************************************************** 
## Outcome Variable: brain_int_win_comp2
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.4313    0.1860    1.3005    1.1425    9.0000   45.0000    0.3542
## 
## Model: 
##                        coeff        se         t         p      LLCI      ULCI
## constant             -1.0240    0.9027   -1.1343    0.2627   -2.8422    0.7942
## mb2_braincomp2        0.4110    0.1585    2.5935    0.0128    0.0918    0.7301
## sex_centered          0.0421    0.1775    0.2373    0.8135   -0.3153    0.3995
## GA_centered           0.1092    0.1559    0.7006    0.4872   -0.2047    0.4231
## BW_centered          -0.0137    0.4584   -0.0298    0.9764   -0.9370    0.9097
## deliv_mode            0.3438    0.3448    0.9971    0.3240   -0.3507    1.0383
## Fat_%energy           0.0065    0.0236    0.2748    0.7848   -0.0410    0.0540
## Fibre.per.1000kcal    0.0593    0.0545    1.0883    0.2823   -0.0505    0.1691
## PUFA_%                0.0088    0.0109    0.8130    0.4205   -0.0131    0.0308
## meanFD_centered      -0.8214    5.7446   -0.1430    0.8869  -12.3917   10.7489
## 
## Standardized coefficients:
##                        coeff
## mb2_braincomp2        0.3743
## sex_centered          0.0354
## GA_centered           0.0989
## BW_centered          -0.0043
## deliv_mode            0.1411
## Fat_%energy           0.0385
## Fibre.per.1000kcal    0.1557
## PUFA_%                0.1129
## meanFD_centered      -0.0206
## 
## *********************************************************************** 
## Outcome Variable: cbclintprobtot_y7_pos_boxcox
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.6302    0.3971    1.1125    2.8984   10.0000   44.0000    0.0072
## 
## Model: 
##                         coeff        se         t         p      LLCI      ULCI
## constant               2.1227    0.8468    2.5068    0.0160    0.4161    3.8293
## mb2_braincomp2        -0.3283    0.1571   -2.0890    0.0425   -0.6449   -0.0116
## brain_int_win_comp2    0.6366    0.1379    4.6171    0.0000    0.3587    0.9145
## sex_centered           0.1715    0.1642    1.0440    0.3022   -0.1595    0.5025
## GA_centered           -0.0188    0.1449   -0.1297    0.8974   -0.3109    0.2733
## BW_centered           -0.0557    0.4240   -0.1314    0.8961   -0.9102    0.7988
## deliv_mode            -0.5365    0.3224   -1.6640    0.1032   -1.1863    0.1133
## Fat_%energy           -0.0020    0.0218   -0.0931    0.9262   -0.0460    0.0420
## Fibre.per.1000kcal    -0.0411    0.0511   -0.8042    0.4256   -0.1440    0.0619
## PUFA_%                 0.0117    0.0101    1.1580    0.2531   -0.0087    0.0322
## meanFD_centered       -0.8276    5.3145   -0.1557    0.8770  -11.5383    9.8831
## 
## Standardized coefficients:
##                         coeff
## mb2_braincomp2        -0.2814
## brain_int_win_comp2    0.5990
## sex_centered           0.1358
## GA_centered           -0.0160
## BW_centered           -0.0165
## deliv_mode            -0.2072
## Fat_%energy           -0.0111
## Fibre.per.1000kcal    -0.1015
## PUFA_%                 0.1413
## meanFD_centered       -0.0195
## 
## *********************************************************************** 
## Bootstrapping progress:
## 
  |                                                                    
  |                                                              |   0%
  |                                                                    
  |                                                              |   1%
  |                                                                    
  |>                                                             |   1%
  |                                                                    
  |>                                                             |   2%
  |                                                                    
  |>>                                                            |   2%
  |                                                                    
  |>>                                                            |   3%
  |                                                                    
  |>>                                                            |   4%
  |                                                                    
  |>>>                                                           |   4%
  |                                                                    
  |>>>                                                           |   5%
  |                                                                    
  |>>>                                                           |   6%
  |                                                                    
  |>>>>                                                          |   6%
  |                                                                    
  |>>>>                                                          |   7%
  |                                                                    
  |>>>>>                                                         |   7%
  |                                                                    
  |>>>>>                                                         |   8%
  |                                                                    
  |>>>>>                                                         |   9%
  |                                                                    
  |>>>>>>                                                        |   9%
  |                                                                    
  |>>>>>>                                                        |  10%
  |                                                                    
  |>>>>>>>                                                       |  10%
  |                                                                    
  |>>>>>>>                                                       |  11%
  |                                                                    
  |>>>>>>>                                                       |  12%
  |                                                                    
  |>>>>>>>>                                                      |  12%
  |                                                                    
  |>>>>>>>>                                                      |  13%
  |                                                                    
  |>>>>>>>>                                                      |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  16%
  |                                                                    
  |>>>>>>>>>>                                                    |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  18%
  |                                                                    
  |>>>>>>>>>>>                                                   |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  21%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  24%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  26%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  29%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  32%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  34%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  37%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  39%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  42%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  45%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  47%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  50%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  53%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  55%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  58%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  61%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  63%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  66%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  68%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  71%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  74%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  76%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  79%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  82%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  84%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  87%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  89%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  92%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  95%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  97%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
## 
## **************** DIRECT AND INDIRECT EFFECTS OF X ON Y ****************
## 
## Direct effect of X on Y:
##      effect        se         t         p      LLCI      ULCI     c'_cs
##     -0.3283    0.1571   -2.0890    0.0425   -0.6449   -0.0116   -0.2813
## 
## Indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp2    0.2616    0.1253    0.0611    0.5430
## 
## Completely standardized indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp2    0.2242    0.1030    0.0533    0.4595
## 
## ******************** ANALYSIS NOTES AND ERRORS ************************ 
## 
## Level of confidence for all confidence intervals in output: 95
## 
## Number of bootstraps for percentile bootstrap confidence intervals: 5000
# faith as the x-variable iwth each brain component
process(data=all_data, y="cbclintprobtot_y7_pos_boxcox", x="faith_pd", m=c("brain_int_win_comp1"), cov=c("sex_centered", "GA_centered", "BW_centered", "deliv_mode", "Fat_%energy", "Fibre.per.1000kcal", "PUFA_%", "meanFD_centered"), model=4, seed=100770, stand=1) # 
## 
## ********************* PROCESS for R Version 4.3.1 ********************* 
##  
##            Written by Andrew F. Hayes, Ph.D.  www.afhayes.com              
##    Documentation available in Hayes (2022). www.guilford.com/p/hayes3   
##  
## *********************************************************************** 
##                                     
## Model : 4                           
##     Y : cbclintprobtot_y7_pos_boxcox
##     X : faith_pd                    
##     M : brain_int_win_comp1         
## 
## Covariates: 
##        sex_centered GA_centered BW_centered deliv_mode Fat_%energy Fibre.per.1000kcal PUFA_% meanFD_centered
## 
## Sample size: 55
## 
## Custom seed: 100770
## 
## 
## *********************************************************************** 
## Outcome Variable: brain_int_win_comp1
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.4144    0.1717    1.2324    1.0368    9.0000   45.0000    0.4266
## 
## Model: 
##                        coeff        se         t         p      LLCI      ULCI
## constant              0.3462    0.9125    0.3794    0.7062   -1.4917    2.1841
## faith_pd             -0.2427    0.1109   -2.1874    0.0339   -0.4661   -0.0192
## sex_centered          0.0167    0.1787    0.0932    0.9261   -0.3433    0.3767
## GA_centered           0.2885    0.1527    1.8888    0.0654   -0.0191    0.5961
## BW_centered          -0.4478    0.4557   -0.9826    0.3311   -1.3656    0.4701
## deliv_mode           -0.4354    0.3548   -1.2270    0.2262   -1.1500    0.2793
## Fat_%energy           0.0191    0.0238    0.8050    0.4251   -0.0287    0.0670
## Fibre.per.1000kcal    0.0467    0.0611    0.7641    0.4488   -0.0764    0.1698
## PUFA_%                0.0053    0.0104    0.5034    0.6171   -0.0158    0.0263
## meanFD_centered       4.6309    5.5184    0.8392    0.4058   -6.4838   15.7455
## 
## Standardized coefficients:
##                        coeff
## faith_pd             -0.3798
## sex_centered          0.0146
## GA_centered           0.2709
## BW_centered          -0.1459
## deliv_mode           -0.1852
## Fat_%energy           0.1172
## Fibre.per.1000kcal    0.1271
## PUFA_%                0.0705
## meanFD_centered       0.1201
## 
## *********************************************************************** 
## Outcome Variable: cbclintprobtot_y7_pos_boxcox
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.5785    0.3347    1.2277    2.2136   10.0000   44.0000    0.0347
## 
## Model: 
##                         coeff        se         t         p      LLCI      ULCI
## constant               1.8463    0.9122    2.0241    0.0491    0.0079    3.6848
## faith_pd              -0.1313    0.1165   -1.1276    0.2656   -0.3660    0.1034
## brain_int_win_comp1    0.4792    0.1488    3.2210    0.0024    0.1794    0.7791
## sex_centered           0.0888    0.1784    0.4980    0.6210   -0.2707    0.4484
## GA_centered            0.0180    0.1584    0.1137    0.9100   -0.3012    0.3372
## BW_centered           -0.1329    0.4597   -0.2891    0.7738   -1.0593    0.7935
## deliv_mode            -0.3872    0.3600   -1.0755    0.2880   -1.1128    0.3384
## Fat_%energy            0.0065    0.0239    0.2731    0.7861   -0.0416    0.0547
## Fibre.per.1000kcal     0.0407    0.0614    0.6624    0.5111   -0.0830    0.1644
## PUFA_%                 0.0164    0.0105    1.5680    0.1240   -0.0047    0.0375
## meanFD_centered       -4.6452    5.5507   -0.8369    0.4072  -15.8321    6.5417
## 
## Standardized coefficients:
##                         coeff
## faith_pd              -0.1866
## brain_int_win_comp1    0.4352
## sex_centered           0.0703
## GA_centered            0.0153
## BW_centered           -0.0393
## deliv_mode            -0.1495
## Fat_%energy            0.0362
## Fibre.per.1000kcal     0.1006
## PUFA_%                 0.1980
## meanFD_centered       -0.1094
## 
## *********************************************************************** 
## Bootstrapping progress:
## 
  |                                                                    
  |                                                              |   0%
  |                                                                    
  |                                                              |   1%
  |                                                                    
  |>                                                             |   1%
  |                                                                    
  |>                                                             |   2%
  |                                                                    
  |>>                                                            |   2%
  |                                                                    
  |>>                                                            |   3%
  |                                                                    
  |>>                                                            |   4%
  |                                                                    
  |>>>                                                           |   4%
  |                                                                    
  |>>>                                                           |   5%
  |                                                                    
  |>>>                                                           |   6%
  |                                                                    
  |>>>>                                                          |   6%
  |                                                                    
  |>>>>                                                          |   7%
  |                                                                    
  |>>>>>                                                         |   7%
  |                                                                    
  |>>>>>                                                         |   8%
  |                                                                    
  |>>>>>                                                         |   9%
  |                                                                    
  |>>>>>>                                                        |   9%
  |                                                                    
  |>>>>>>                                                        |  10%
  |                                                                    
  |>>>>>>>                                                       |  10%
  |                                                                    
  |>>>>>>>                                                       |  11%
  |                                                                    
  |>>>>>>>                                                       |  12%
  |                                                                    
  |>>>>>>>>                                                      |  12%
  |                                                                    
  |>>>>>>>>                                                      |  13%
  |                                                                    
  |>>>>>>>>                                                      |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  16%
  |                                                                    
  |>>>>>>>>>>                                                    |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  18%
  |                                                                    
  |>>>>>>>>>>>                                                   |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  21%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  24%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  26%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  29%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  32%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  34%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  37%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  39%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  42%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  45%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  47%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  50%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  53%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  55%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  58%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  61%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  63%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  66%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  68%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  71%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  74%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  76%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  79%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  82%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  84%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  87%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  89%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  92%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  95%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  97%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
## 
## **************** DIRECT AND INDIRECT EFFECTS OF X ON Y ****************
## 
## Direct effect of X on Y:
##      effect        se         t         p      LLCI      ULCI     c'_cs
##     -0.1313    0.1165   -1.1276    0.2656   -0.3660    0.1034   -0.1866
## 
## Indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp1   -0.1163    0.0721   -0.2760    0.0030
## 
## Completely standardized indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp1   -0.1653    0.1001   -0.3877    0.0049
## 
## ******************** ANALYSIS NOTES AND ERRORS ************************ 
## 
## Level of confidence for all confidence intervals in output: 95
## 
## Number of bootstraps for percentile bootstrap confidence intervals: 5000
process(data=all_data, y="cbclintprobtot_y7_pos_boxcox", x="faith_pd", m=c("brain_int_win_comp2"), cov=c("sex_centered", "GA_centered", "BW_centered", "deliv_mode", "Fat_%energy", "Fibre.per.1000kcal", "PUFA_%", "meanFD_centered"), model=4, seed=100770, stand=1) # 
## 
## ********************* PROCESS for R Version 4.3.1 ********************* 
##  
##            Written by Andrew F. Hayes, Ph.D.  www.afhayes.com              
##    Documentation available in Hayes (2022). www.guilford.com/p/hayes3   
##  
## *********************************************************************** 
##                                     
## Model : 4                           
##     Y : cbclintprobtot_y7_pos_boxcox
##     X : faith_pd                    
##     M : brain_int_win_comp2         
## 
## Covariates: 
##        sex_centered GA_centered BW_centered deliv_mode Fat_%energy Fibre.per.1000kcal PUFA_% meanFD_centered
## 
## Sample size: 55
## 
## Custom seed: 100770
## 
## 
## *********************************************************************** 
## Outcome Variable: brain_int_win_comp2
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.2607    0.0680    1.4890    0.3645    9.0000   45.0000    0.9460
## 
## Model: 
##                        coeff        se         t         p      LLCI      ULCI
## constant             -0.8552    1.0030   -0.8526    0.3984   -2.8753    1.1650
## faith_pd             -0.0511    0.1219   -0.4187    0.6774   -0.2967    0.1945
## sex_centered         -0.0225    0.1965   -0.1145    0.9094   -0.4182    0.3732
## GA_centered           0.0311    0.1679    0.1850    0.8540   -0.3071    0.3692
## BW_centered           0.1120    0.5009    0.2236    0.8241   -0.8969    1.1209
## deliv_mode            0.3688    0.3900    0.9455    0.3495   -0.4168    1.1543
## Fat_%energy           0.0102    0.0261    0.3890    0.6991   -0.0425    0.0628
## Fibre.per.1000kcal    0.0898    0.0672    1.3363    0.1882   -0.0455    0.2250
## PUFA_%                0.0043    0.0115    0.3746    0.7097   -0.0188    0.0274
## meanFD_centered       1.5825    6.0658    0.2609    0.7954  -10.6347   13.7997
## 
## Standardized coefficients:
##                        coeff
## faith_pd             -0.0772
## sex_centered         -0.0189
## GA_centered           0.0282
## BW_centered           0.0352
## deliv_mode            0.1514
## Fat_%energy           0.0604
## Fibre.per.1000kcal    0.2358
## PUFA_%                0.0552
## meanFD_centered       0.0396
## 
## *********************************************************************** 
## Outcome Variable: cbclintprobtot_y7_pos_boxcox
## 
## Model Summary: 
##           R      R-sq       MSE         F       df1       df2         p
##      0.6305    0.3975    1.1118    2.9028   10.0000   44.0000    0.0071
## 
## Model: 
##                         coeff        se         t         p      LLCI      ULCI
## constant               2.4534    0.8737    2.8082    0.0074    0.6927    4.2142
## faith_pd              -0.2213    0.1056   -2.0960    0.0419   -0.4340   -0.0085
## brain_int_win_comp2    0.5159    0.1288    4.0051    0.0002    0.2563    0.7755
## sex_centered           0.1084    0.1698    0.6386    0.5264   -0.2338    0.4506
## GA_centered            0.1402    0.1451    0.9663    0.3392   -0.1522    0.4327
## BW_centered           -0.4053    0.4331   -0.9358    0.3545   -1.2780    0.4675
## deliv_mode            -0.7861    0.3404   -2.3096    0.0257   -1.4720   -0.1001
## Fat_%energy            0.0105    0.0226    0.4621    0.6463   -0.0351    0.0560
## Fibre.per.1000kcal     0.0167    0.0592    0.2828    0.7787   -0.1025    0.1360
## PUFA_%                 0.0167    0.0099    1.6801    0.1000   -0.0033    0.0367
## meanFD_centered       -3.2424    5.2454   -0.6181    0.5397  -13.8139    7.3292
## 
## Standardized coefficients:
##                         coeff
## faith_pd              -0.3145
## brain_int_win_comp2    0.4854
## sex_centered           0.0858
## GA_centered            0.1195
## BW_centered           -0.1199
## deliv_mode            -0.3036
## Fat_%energy            0.0585
## Fibre.per.1000kcal     0.0413
## PUFA_%                 0.2016
## meanFD_centered       -0.0764
## 
## *********************************************************************** 
## Bootstrapping progress:
## 
  |                                                                    
  |                                                              |   0%
  |                                                                    
  |                                                              |   1%
  |                                                                    
  |>                                                             |   1%
  |                                                                    
  |>                                                             |   2%
  |                                                                    
  |>>                                                            |   2%
  |                                                                    
  |>>                                                            |   3%
  |                                                                    
  |>>                                                            |   4%
  |                                                                    
  |>>>                                                           |   4%
  |                                                                    
  |>>>                                                           |   5%
  |                                                                    
  |>>>                                                           |   6%
  |                                                                    
  |>>>>                                                          |   6%
  |                                                                    
  |>>>>                                                          |   7%
  |                                                                    
  |>>>>>                                                         |   7%
  |                                                                    
  |>>>>>                                                         |   8%
  |                                                                    
  |>>>>>                                                         |   9%
  |                                                                    
  |>>>>>>                                                        |   9%
  |                                                                    
  |>>>>>>                                                        |  10%
  |                                                                    
  |>>>>>>>                                                       |  10%
  |                                                                    
  |>>>>>>>                                                       |  11%
  |                                                                    
  |>>>>>>>                                                       |  12%
  |                                                                    
  |>>>>>>>>                                                      |  12%
  |                                                                    
  |>>>>>>>>                                                      |  13%
  |                                                                    
  |>>>>>>>>                                                      |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  14%
  |                                                                    
  |>>>>>>>>>                                                     |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  15%
  |                                                                    
  |>>>>>>>>>>                                                    |  16%
  |                                                                    
  |>>>>>>>>>>                                                    |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  17%
  |                                                                    
  |>>>>>>>>>>>                                                   |  18%
  |                                                                    
  |>>>>>>>>>>>                                                   |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  19%
  |                                                                    
  |>>>>>>>>>>>>                                                  |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  20%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  21%
  |                                                                    
  |>>>>>>>>>>>>>                                                 |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  22%
  |                                                                    
  |>>>>>>>>>>>>>>                                                |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  23%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  24%
  |                                                                    
  |>>>>>>>>>>>>>>>                                               |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  25%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  26%
  |                                                                    
  |>>>>>>>>>>>>>>>>                                              |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  27%
  |                                                                    
  |>>>>>>>>>>>>>>>>>                                             |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  28%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  29%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>                                            |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  30%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>                                           |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  31%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  32%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>                                          |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  33%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  34%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>                                         |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  35%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>                                        |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  36%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  37%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>                                       |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  38%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  39%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>                                      |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  40%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>                                     |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  41%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  42%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                    |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  43%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>                                   |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  44%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  45%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                  |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  46%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  47%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                 |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  48%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                                |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  49%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  50%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                               |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  51%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                              |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  52%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  53%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                             |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  54%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  55%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                            |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  56%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                           |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  57%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  58%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  59%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                         |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  60%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  61%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                        |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  62%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  63%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                       |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  64%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                      |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  65%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  66%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  67%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  68%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  69%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                   |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  70%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  71%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                  |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  72%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                 |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  73%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  74%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  75%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  76%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>               |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  77%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>              |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  78%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  79%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  80%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>            |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  81%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  82%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>           |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  83%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  84%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>          |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  85%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  86%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  87%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  88%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  89%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>       |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  90%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>      |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  91%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  92%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  93%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  94%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  95%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  96%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  97%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  98%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|  99%
  |                                                                    
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
## 
## **************** DIRECT AND INDIRECT EFFECTS OF X ON Y ****************
## 
## Direct effect of X on Y:
##      effect        se         t         p      LLCI      ULCI     c'_cs
##     -0.2213    0.1056   -2.0960    0.0419   -0.4340   -0.0085   -0.3144
## 
## Indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp2   -0.0263    0.0786   -0.1856    0.1234
## 
## Completely standardized indirect effect(s) of X on Y:
##                        Effect    BootSE  BootLLCI  BootULCI
## brain_int_win_comp2   -0.0374    0.1127   -0.2673    0.1828
## 
## ******************** ANALYSIS NOTES AND ERRORS ************************ 
## 
## Level of confidence for all confidence intervals in output: 95
## 
## Number of bootstraps for percentile bootstrap confidence intervals: 5000

Figure 1: Combined Brain Signatures and Microbial Patterns

#combine the graphs generated in chunks above
library(patchwork)
plot_layout(brain_c1 + mb_pattern1 + plot_spacer() + brain_c2 + mb_pattern2 + mb_pattern3, nrow=2) 
## $ncol

## 
## $nrow
## [1] 2
## 
## $byrow
## NULL
## 
## $widths
## NULL
## 
## $heights
## NULL
## 
## $guides
## NULL
## 
## $tag_level
## NULL
## 
## $axes
## NULL
## 
## $axis_titles
## NULL
## 
## $design
## NULL
## 
## attr(,"class")
## [1] "plot_layout"
ggsave('figures_demo/Figure1_combined_aligned.jpg', width = 12, height=8, units="in", dpi=1000)

Descriptives

Table 1: Descriptive Statistics

In the real dataset, centered variables (meanFD, GA, BW, sex) are added back in their raw form before generating descriptives, so that the values make sense. Also, the CBCL t-score is reported on.

For the purposes of the demo, we will simply use the simulated centered variables, and the simulated CBCL raw score, in the code

# means and sds 
means_etc <- metadata_comp %>% dplyr::select(
  subID, # numbers in var names below are for ordering
  meanFD_centered, # in the real dataset, this is the raw variable, meanFD
  cbclintprobtot_y7, # in the real dataset, this is the t-score
  GA_centered, # in the real dataset, this is the raw variable, GA
  BW_centered, # in the real dataset, this is the raw variable, BW
  shannon_entropy,
  observed_features,
  pielou_evenness,
  faith_pd,
  `Protein_%energy`,
  `Fat_%energy`,
  `CHO_%energy`,
  Fibre.per.1000kcal,
  `SatFat_%`,
  `MUFA_%`,
  `PUFA_%`
) %>% pivot_longer(
  cols = !subID,
  names_to = "variable",
  values_to = "value"
) %>% group_by(variable) %>% 
  summarise(Mean = round(mean(value, na.rm=TRUE), digits=2), SD = round(sd(value, na.rm=TRUE), digits=2), Min = round(min(value, na.rm=TRUE), digits=2), Max = round(max(value, na.rm=TRUE),digits=2))

colnames(means_etc) <- c("Measure", "Mean", "SD", "Min", "Max")

write_csv(means_etc, "tables_demo/Table1.csv")

# ns and percentages (ethnicity, sex, birth method, age stopped breastfeeding, )
metadata_comp %>% group_by(ethnicity) %>% summarise(n = n()) %>%
  mutate(freq = n / sum(n)) %>% arrange(desc(n))
## # A tibble: 3 × 3
##   ethnicity     n   freq
##   <chr>     <int>  <dbl>
## 1 chinese      43 0.782 
## 2 malay         8 0.145 
## 3 indian        4 0.0727
metadata_comp %>% group_by(sex_centered) %>% summarise(n = n()) %>%
  mutate(freq = n / sum(n)) %>% arrange(desc(n)) # -1=female
## # A tibble: 2 × 3
##   sex_centered     n  freq
##          <dbl> <int> <dbl>
## 1            1    35 0.636
## 2           -1    20 0.364
metadata_comp %>% group_by(any_bf_months) %>% summarise(n = n()) %>%
  mutate(freq = n / sum(n)) %>% arrange(desc(n))
## # A tibble: 5 × 3
##   any_bf_months     n  freq
##   <fct>         <int> <dbl>
## 1 6M_to_12M        14 0.255
## 2 <NA>             13 0.236
## 3 3M_to_6M         11 0.2  
## 4 >12M             11 0.2  
## 5 1M_to_3M          6 0.109
metadata_comp %>% group_by(deliv_mode) %>% summarise(n = n()) %>%
  mutate(freq = n / sum(n)) %>% arrange(desc(n))
## # A tibble: 2 × 3
##   deliv_mode     n  freq
##        <dbl> <int> <dbl>
## 1          0    37 0.673
## 2          1    18 0.327
# percent missing data check 
metadata_comp %>% dplyr::count(is.na(Fibre.per.1000kcal))
## # A tibble: 1 × 2
##   `is.na(Fibre.per.1000kcal)`     n
##   <lgl>                       <int>
## 1 FALSE                          55

Cronbach’s Alpha for CBCL Internalizing Symptom Items in This Sample

# merge cbcl raw items with anlytic sample ids
analysis_cbcl <- sim_data %>% 
  dplyr::select(contains("cbclq")) 

# recode the raw responses into numeric 
analysis_cbcl_clean <- analysis_cbcl %>% dplyr::mutate(
  across(contains("cbcl"), ~case_when(
    . == "Not True (as far as you know)" ~ 0,
    . == "Somewhat or Sometimes True" ~ 1,
    . == "Very True or Often True" ~ 2,
    . == "-9999" ~ NA
  ))
) 

psych::alpha(analysis_cbcl_clean) # standardized alpha = 0.81
## Warning in psych::alpha(analysis_cbcl_clean): Some items were negatively correlated with the total scale and probably 
## should be reversed.  
## To do this, run the function again with the 'check.keys=TRUE' option
## Some items ( cbclq5_y7 cbclq14_y7 cbclq30_y7 cbclq31_y7 cbclq32_y7 cbclq49_y7 cbclq56a_y7 cbclq56b_y7 cbclq56c_y7 cbclq56d_y7 cbclq65_y7 cbclq71_y7 cbclq102_y7 ) were negatively correlated with the total scale and 
## probably should be reversed.  
## To do this, run the function again with the 'check.keys=TRUE' option
## 
## Reliability analysis   
## Call: psych::alpha(x = analysis_cbcl_clean)
## 
##   raw_alpha std.alpha G6(smc) average_r   S/N  ase mean   sd median_r
##      -0.19     -0.16    0.38   -0.0044 -0.14 0.21 0.14 0.06   -0.048
## 
##     95% confidence boundaries 
##          lower alpha upper
## Feldt    -0.64 -0.19  0.19
## Duhachek -0.59 -0.19  0.22
## 
##  Reliability if an item is dropped:
##             raw_alpha std.alpha G6(smc) average_r    S/N alpha se var.r  med.r
## cbclq5_y7      -0.178    -0.151    0.37   -0.0042 -0.131     0.21 0.015 -0.048
## cbclq14_y7     -0.094    -0.072    0.43   -0.0022 -0.067     0.19 0.015 -0.047
## cbclq29_y7     -0.204    -0.189    0.35   -0.0052 -0.159     0.21 0.015 -0.048
## cbclq30_y7     -0.175    -0.144    0.39   -0.0041 -0.126     0.21 0.015 -0.046
## cbclq31_y7     -0.068    -0.061    0.43   -0.0019 -0.057     0.19 0.015 -0.046
## cbclq32_y7     -0.191    -0.140    0.37   -0.0040 -0.122     0.21 0.015 -0.049
## cbclq33_y7     -0.191    -0.166    0.35   -0.0046 -0.143     0.21 0.015 -0.048
## cbclq35_y7     -0.258    -0.238    0.31   -0.0062 -0.193     0.22 0.014 -0.047
## cbclq42_y7     -0.223    -0.229    0.31   -0.0061 -0.187     0.21 0.015 -0.055
## cbclq45_y7     -0.165    -0.098    0.41   -0.0029 -0.090     0.20 0.015 -0.047
## cbclq47_y7     -0.186    -0.189    0.36   -0.0052 -0.159     0.21 0.015 -0.049
## cbclq49_y7     -0.157    -0.121    0.38   -0.0035 -0.108     0.20 0.015 -0.048
## cbclq50_y7     -0.106    -0.052    0.43   -0.0016 -0.049     0.19 0.015 -0.046
## cbclq51_y7     -0.217    -0.200    0.34   -0.0054 -0.166     0.21 0.015 -0.046
## cbclq52_y7     -0.210    -0.188    0.34   -0.0051 -0.159     0.21 0.014 -0.046
## cbclq54_y7     -0.177    -0.172    0.36   -0.0048 -0.147     0.20 0.015 -0.047
## cbclq56a_y7    -0.186    -0.187    0.36   -0.0051 -0.158     0.21 0.015 -0.048
## cbclq56b_y7    -0.077    -0.040    0.44   -0.0012 -0.039     0.19 0.015 -0.046
## cbclq56c_y7    -0.213    -0.184    0.35   -0.0050 -0.156     0.21 0.015 -0.047
## cbclq56d_y7    -0.165    -0.150    0.39   -0.0042 -0.131     0.20 0.015 -0.048
## cbclq56e_y7    -0.343    -0.229    0.34   -0.0061 -0.186     0.24 0.015 -0.055
## cbclq56f_y7    -0.108    -0.078    0.42   -0.0023 -0.072     0.19 0.015 -0.048
## cbclq56g_y7    -0.246    -0.254    0.31   -0.0066 -0.203     0.22 0.015 -0.048
## cbclq65_y7     -0.191    -0.154    0.38   -0.0043 -0.133     0.21 0.015 -0.048
## cbclq69_y7     -0.210    -0.221    0.34   -0.0059 -0.181     0.21 0.015 -0.052
## cbclq71_y7     -0.238    -0.213    0.33   -0.0057 -0.176     0.22 0.015 -0.055
## cbclq75_y7     -0.169    -0.130    0.39   -0.0037 -0.115     0.20 0.015 -0.048
## cbclq91_y7     -0.204    -0.197    0.34   -0.0053 -0.165     0.21 0.015 -0.055
## cbclq102_y7    -0.155    -0.093    0.41   -0.0028 -0.085     0.20 0.015 -0.046
## cbclq103_y7    -0.231    -0.231    0.31   -0.0061 -0.188     0.21 0.015 -0.048
## cbclq111_y7    -0.142    -0.116    0.39   -0.0034 -0.104     0.20 0.015 -0.046
## cbclq112_y7    -0.182    -0.170    0.36   -0.0047 -0.145     0.21 0.015 -0.046
## 
##  Item statistics 
##              n   raw.r  std.r   r.cor  r.drop  mean   sd
## cbclq5_y7   66  0.1005  0.155  0.0775 -0.0383 0.076 0.27
## cbclq14_y7  66 -0.0789 -0.028 -0.2546 -0.2431 0.121 0.33
## cbclq29_y7  66  0.3204  0.236  0.2274 -0.0073 0.394 0.63
## cbclq30_y7  66  0.0537  0.140  0.0507 -0.0554 0.045 0.21
## cbclq31_y7  66  0.0539 -0.056 -0.2967 -0.2084 0.273 0.51
## cbclq32_y7  66  0.2939  0.130  0.0604 -0.0214 0.394 0.60
## cbclq33_y7  66  0.2133  0.188  0.1748 -0.0115 0.242 0.43
## cbclq35_y7  66  0.3287  0.332  0.4093  0.2108 0.061 0.24
## cbclq42_y7  66  0.2373  0.315  0.3937  0.0681 0.121 0.33
## cbclq45_y7  66  0.0778  0.036 -0.1398 -0.0728 0.091 0.29
## cbclq47_y7  66  0.1704  0.236  0.2180 -0.0177 0.152 0.36
## cbclq49_y7  66  0.1334  0.088 -0.0142 -0.0759 0.152 0.40
## cbclq50_y7  66 -0.0699 -0.080 -0.3146 -0.2258 0.106 0.31
## cbclq51_y7  66  0.2061  0.257  0.2697  0.0987 0.045 0.21
## cbclq52_y7  66  0.1905  0.234  0.2509  0.0527 0.076 0.27
## cbclq54_y7  66  0.1374  0.200  0.1723 -0.0390 0.091 0.34
## cbclq56a_y7 66  0.1870  0.232  0.1909 -0.0199 0.106 0.40
## cbclq56b_y7 66 -0.1275 -0.110 -0.3645 -0.2882 0.121 0.33
## cbclq56c_y7 66  0.1956  0.226  0.2209  0.0718 0.061 0.24
## cbclq56d_y7 66  0.1467  0.154  0.0096 -0.0603 0.106 0.40
## cbclq56e_y7 66  0.4448  0.314  0.3375  0.2231 0.182 0.46
## cbclq56f_y7 66 -0.0067 -0.014 -0.2319 -0.1910 0.152 0.36
## cbclq56g_y7 66  0.2954  0.361  0.4478  0.1756 0.061 0.24
## cbclq65_y7  66  0.1644  0.162  0.0723 -0.0067 0.121 0.33
## cbclq69_y7  66  0.2518  0.298  0.3175  0.0184 0.167 0.45
## cbclq71_y7  66  0.3351  0.284  0.3081  0.0421 0.348 0.57
## cbclq75_y7  66  0.2408  0.108  0.0115 -0.0486 0.409 0.55
## cbclq91_y7  66  0.1605  0.252  0.2675  0.0973 0.015 0.12
## cbclq102_y7 66 -0.0225  0.023 -0.1556 -0.1306 0.045 0.21
## cbclq103_y7 66  0.2505  0.318  0.3909  0.1147 0.076 0.27
## cbclq111_y7 66 -0.0373  0.077 -0.0306 -0.1603 0.061 0.24
## cbclq112_y7 66  0.0958  0.195  0.1835 -0.0294 0.061 0.24
## 
## Non missing response frequency for each item
##                0    1    2 miss
## cbclq5_y7   0.92 0.08 0.00    0
## cbclq14_y7  0.88 0.12 0.00    0
## cbclq29_y7  0.68 0.24 0.08    0
## cbclq30_y7  0.95 0.05 0.00    0
## cbclq31_y7  0.76 0.21 0.03    0
## cbclq32_y7  0.67 0.27 0.06    0
## cbclq33_y7  0.76 0.24 0.00    0
## cbclq35_y7  0.94 0.06 0.00    0
## cbclq42_y7  0.88 0.12 0.00    0
## cbclq45_y7  0.91 0.09 0.00    0
## cbclq47_y7  0.85 0.15 0.00    0
## cbclq49_y7  0.86 0.12 0.02    0
## cbclq50_y7  0.89 0.11 0.00    0
## cbclq51_y7  0.95 0.05 0.00    0
## cbclq52_y7  0.92 0.08 0.00    0
## cbclq54_y7  0.92 0.06 0.02    0
## cbclq56a_y7 0.92 0.05 0.03    0
## cbclq56b_y7 0.88 0.12 0.00    0
## cbclq56c_y7 0.94 0.06 0.00    0
## cbclq56d_y7 0.92 0.05 0.03    0
## cbclq56e_y7 0.85 0.12 0.03    0
## cbclq56f_y7 0.85 0.15 0.00    0
## cbclq56g_y7 0.94 0.06 0.00    0
## cbclq65_y7  0.88 0.12 0.00    0
## cbclq69_y7  0.86 0.11 0.03    0
## cbclq71_y7  0.70 0.26 0.05    0
## cbclq75_y7  0.62 0.35 0.03    0
## cbclq91_y7  0.98 0.02 0.00    0
## cbclq102_y7 0.95 0.05 0.00    0
## cbclq103_y7 0.92 0.08 0.00    0
## cbclq111_y7 0.94 0.06 0.00    0
## cbclq112_y7 0.94 0.06 0.00    0